QBoxLayout composition



  • One of widgets (playground) is invisible:
    @ QHBoxLayout *colLayout = new QHBoxLayout;
    colLayout->addWidget(colLabel);
    colLayout->addWidget(colSlider);
    colLayout->addWidget(colSpinBox);

    QHBoxLayout *rowLayout = new QHBoxLayout;
    rowLayout->addWidget(rowLabel);
    rowLayout->addWidget(rowSlider);
    rowLayout->addWidget(rowSpinBox);
    
    QHBoxLayout *genIntevalLayout = new QHBoxLayout;
    genIntevalLayout->addWidget(genIntervalSlider);
    genIntevalLayout->addWidget(genIntervalLineEdit);
    
    QVBoxLayout *editLayout = new QVBoxLayout;
    editLayout->addWidget(sizeLabel, 0, Qt::AlignCenter);
    editLayout->addLayout(colLayout);
    editLayout->addLayout(rowLayout);
    editLayout->addWidget(genIntervalLabel, 0, Qt::AlignCenter);
    editLayout->addLayout(genIntevalLayout);
    editLayout->addStretch();
    editLayout->addLayout(buttonLayout);
    
    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(playground);
    mainLayout->addLayout(editLayout);
    
    QWidget *mainWidget = new QWidget;
    mainWidget->setLayout(mainLayout);
    
    setCentralWidget(mainWidget);
    

    @

    Please tell me, where is my mistake.



  • What is playground? Does it have a reasonable size hint and/or minimum size?



  • it's widget's son
    here is the code:
    @class Playground : public QWidget {
    Q_OBJECT

    public:
    Playground();
    int cols(){return colCount;}
    int rows(){return rowCount;}
    private:
    int colCount;
    int rowCount;
    int interval;
    bool **table;
    QColor lineColor;
    QColor rectColor;
    QTimer *timer;

    void paintEvent(QPaintEvent *);
    void mousePressEvent(QMouseEvent *event);
    void drawTable(QPainter &painter);
    void drawWorld(QPainter &painter);
    

    private slots:
    void newGeneration();
    void startGame();
    void pauseGame();
    void resetGame();
    signals:
    void gameOver();
    public:
    bool isActive();
    };@



  • ok, i solved this problem? by adding @setMinimumSize(rowCount3, colCount3);@ into the constructor of the Playground.
    Thank you)



  • but how can I fix width of the sideLayout?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.