我想将我的 QFrame(绘制几条线)覆盖到 QGridLayout 上,以显示一些连接布局上一些网格的线。但是我无法使用以下代码找到我的行。
QHBoxLayout *basicLayout = new QHBoxLayout(parent);
QVBoxLayout *mapLayout = new QVBoxLayout(); // Grid Map
rightBarLayout = new QVBoxLayout(); // Game status bar
layout = new QGridLayout();
lines = new lineMask(); // A mask overlaying grid to draw lines
layout->addWidget(lines, 0, 0, -1, -1,
Qt::AlignRight);
mapLayout->addLayout(layout);
basicLayout->addLayout(mapLayout);
basicLayout->addLayout(rightBarLayout);
basicLayout->addWidget(lines);
并在行中:
class lineMask: public QFrame
{
private:
QVector<QVector<QLine>> lineGroup;
void paintEvent(QPaintEvent *) override;
QVector<bool> seen;
unsigned int num;
public:
lineMask();
int addLines(QVector<QLine> &);
void removeLines(int idx);
};