[SOLVED] Adding to a QGridLayout the way Creator can.
General and Desktop
7
Posts
2
Posters
1.7k
Views
2
Watching
-
Hi
In Creator you can add widgets to a QGridLayout
and it can add / remove Columns doing so.So If have w1 w2 w3
I can drag between a widget w2 and w3 to get
w1 w2 MyNew w3How can I do this from code / dynamic ? (seems not to be possible)
Thevoid QGridLayout::addWidget(QWidget * widget, int row, int column, Qt::Alignment alignment = 0)
Will replace what ever widget already in row, column, not make room for new one.
Thank you
-
Hi,
Just put the widget on the row/column you want:
QGridLayout *layout = new QGridLayout; layout->addWidget(new QPushButton(tr("Test1")), 0, 0); layout->addWidget(new QPushButton(tr("Test2")), 1, 1); layout->addWidget(new QPushButton(tr("Test3")), 2, 2);
-
Hi,
Just put the widget on the row/column you want:
QGridLayout *layout = new QGridLayout; layout->addWidget(new QPushButton(tr("Test1")), 0, 0); layout->addWidget(new QPushButton(tr("Test2")), 1, 1); layout->addWidget(new QPushButton(tr("Test3")), 2, 2);
-
Indeed, it seems that a replace + add combo is the only way
-
QHorizontalLayout + QVerticalLayout ?
You can also check the sources of designer to see how it's done there
-
QHorizontalLayout + QVerticalLayout ?
You can also check the sources of designer to see how it's done there