Maximize widget upon main window maximize [Solved]
-
-
You probably didn't use "a layout":http://qt-project.org/doc/qt-4.7/layout.html
-
Dear Eddy,
I wrote the following code:
@
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addWidget(ui->treeWidget); setLayout(mainLayout);
}
@
But the tree widget is not resized upon window resize.Can you help ?
Thanks,
Zvika.[edit: please add @code tags around your code next time. It makes it easier to read for us, eddy]
-
At first sight your code looks ok. Are you saying that your border of the treeWidget is not following the size or the contents of the treeWidget don't behave as expected?
[Edit maybe "resizeColumnToContents.":http://qt-project.org/doc/qt-4.8/qtreeview.html#resizeColumnToContents
Is what you need] -
No, the code is wrong.
@
setLayout(mainLayout)
@will failed here, as QMainWindow already has a Layout. (Otherwise, how can QMenuBar, QStatusBar and QToolBar s work?)
You don't need to write such code, just put QTreeWidget to your central Widget, then apply a layout for it. All this can be done in Designer.