rows don't span in a grid layout.
-
Hi,
Here is the code:
Dialog::Dialog(QWidget *parent) : QDialog(parent) , ui(new Ui::Dialog) { ui->setupUi(this); QGridLayout* glayout = new QGridLayout(this); QPushButton* pushButton = new QPushButton("span"); glayout->addWidget(pushButton, 0, 0, 2, 2); glayout->addWidget(new QPushButton("normal"),2,0); } The result: Why doesn't the row span to the next row like the column?
Thank you.
-
Hi,
Here is the code:
Dialog::Dialog(QWidget *parent) : QDialog(parent) , ui(new Ui::Dialog) { ui->setupUi(this); QGridLayout* glayout = new QGridLayout(this); QPushButton* pushButton = new QPushButton("span"); glayout->addWidget(pushButton, 0, 0, 2, 2); glayout->addWidget(new QPushButton("normal"),2,0); } The result: Why doesn't the row span to the next row like the column?
Thank you.
@ntos What makes you think it does not? The QPushButton will not grow vertically and yoiu have nothing else to reference it to in those rows. See this, for example:
#include <QApplication> #include <QGridLayout> #include <QFrame> #include <QPushButton> #include <QWidget> int main(int argc, char **argv) { QApplication app(argc, argv); QWidget w; QGridLayout* glayout = new QGridLayout(&w); QPushButton* pushButton = new QPushButton("span"); glayout->addWidget(pushButton, 0, 0, 2, 2); glayout->addWidget(new QPushButton("normal"),2,0); QFrame *frame = new QFrame(&w); frame->setFrameStyle(QFrame::Box | QFrame::Plain); glayout->addWidget(frame, 0, 2); frame = new QFrame(&w); frame->setFrameStyle(QFrame::Box | QFrame::Plain); glayout->addWidget(frame, 1, 2); frame = new QFrame(&w); frame->setFrameStyle(QFrame::Box | QFrame::Plain); glayout->addWidget(frame, 2, 2); w.resize(640, 480); w.show(); return app.exec(); }Result:

-
N ntos has marked this topic as solved on