I tried to create a widget having the following layout:
I tried several approaches, in my first one, I used a QVBoxLayout to that I added different Widgets that used the QGridLayout (so I would get the horizontal resize in the way I want it).
//pseudo code, just to show what I tried...
myHeaderWidget::myHeaderWidget() {
QGridLayout* layout = new QGridLayout;
layout->addWidget(new QCheckBox(), 0, 0, 1, -1, Qt::AlignRight | Qt::AlignTop);
setLayout(layout);
}
oneOfMyOtherWidgets::oneOfMyOtherWidgets() {
QGridLayout* layout = new QGridLayout;
layout->addWidget(new QCheckBox(), 0, 0, 1, 1, Qt::AlignLeft | Qt::AlignTop);
layout->addWidget(new QPushButton(), 0, 1, 1, -1, Qt::AlignLeft | Qt::AlignTop);
setLayout(layout);
}
mydialog::mydialog() {
QVBoxLayout* layout = new QVBoxLayout;
setLayout(layout);
layout->addWidget(new myHeaderWidget, 0, Qt::AlignRight);
//here was the third widget containing Descr1 and Description2, as
//drawn in image above
layout->addWidget(new oneOfMyOtherWidgets, 0, Qt::AlignLeft);
}
The second approach was to use a QGridWidget as layout for mydialog, and my third approach was to add all those items to the same QGridWidget of mydialog.
All those results in the same, for me strange, behavior: At any time I created those dialog and called show(), one of the following could happen:
May somebody give me a hint, what I did wrong, or show me a way to create the layout I drew in the image?
Found it by myself:
setColumnStretch(0,1);
was missing. The added widgets took the whole space in the cell, but the cell never grew.