0

I want to overlay my QFrame(Draw several lines) onto a QGridLayout, to show some lines connecting some grids on the layout. But I can't find my lines with following code.

    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);

And in 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);
};
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Yy Lee
  • 1
  • I'm a bit confused as to exactly what you're trying to achieve. Having said that, one thing that does stand out is that you've added `lines` to two layouts -- both `layout` *and* `basicLayout`. – G.M. Oct 29 '21 at 16:28
  • @G.M. Thanks a lot! I've solved my problem, need I delete this problem now? (This is my first question in stackOverflow. – Yy Lee Oct 30 '21 at 02:36

0 Answers0