Reputation:
Here's my constructor:
DiskUsage::DiskUsage() {
pathLineEdit = new QLineEdit;
generateButton = new QPushButton(tr("Generate"));
pathGroupBoxLayout = new QHBoxLayout;
pathGroupBoxLayout->addWidget(pathLineEdit);
pathGroupBoxLayout->addWidget(generateButton);
pathGroupBox = new QGroupBox(tr("Path"));
pathGroupBox->setLayout(pathGroupBoxLayout);
chartGroupBox = new QGroupBox(tr("Chart"));
mainLayout = new QVBoxLayout;
mainLayout->addWidget(pathGroupBox);
mainLayout->addWidget(chartGroupBox);
setLayout(mainLayout);
}
How can I get the pathGroupBoxLayout (which is a QHBoxLayout) a fixed height? I want that when the window is vertically resized, only the chartGroupBox resizes, but not the pathGroupBoxLayout.
Upvotes: 3
Views: 2813
Reputation: 662
just set verticalPolicy of your groupBox to fixed.
you can use
pathGroupBox->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
for more options and information checkout this link
Upvotes: 3
Reputation: 3989
Not sure I understand you correctly. You seem to get a little bit wrong. The pathGroupBoxLayout is a layout inside your pathGroupBox. I does not govern the size of your pathGroupBox. You can't and certainly don't want to 'fix' the size of your pathGroupBoxLayout.
If you want to have your pathGroupBox not resizing, you give it (not the layout) a fixed size. pathGroupBox->setFixedHeight().
Upvotes: 0