Make QTableWidget expand when dialog window size is changed
-
wrote on 9 Nov 2011, 14:53 last edited by
I have a tablewidget, and a textEdit, and cancel +okay bottons
I want these widgets to stay in the relative position to each other, and the tablewidget to expand if the dialog window is expanded or size changed...how can i do that?
-
wrote on 9 Nov 2011, 15:03 last edited by
Use a layout manager, "gridlayout":http://doc.qt.nokia.com/latest/qgridlayout.html should work for you.
-
wrote on 9 Nov 2011, 16:01 last edited by
Please read the "introduction on layout management":http://doc.qt.nokia.com/latest/layout.html from the documentation.
For positioning the cancel and OK buttons, I would recommend you look into using a QDialogButtonBox. It will automatically layout and order the buttons for you in the way your platform prescribes.
-
wrote on 9 Nov 2011, 20:13 last edited by
so i have this
@QGridLayout *layout=new QGridLayout();
ui->tableWidget->setSizePolicy(QSizePolicy::Expanding);
layout->addWidget(ui->tableWidget,0,0,-1,-1,Qt::AlignVCenter);
layout->addWidget(ui->textEdit_2,1,0,1,2,Qt::AlignLeft);
layout->addWidget(ui->cancel,1,1);
layout->addWidget(ui->ok,1,2);
this->setLayout(layout); @but only a tiny box is created for viewing of each widget... the widget doesnt fill up the cell in the grid... and the setSizePolicy gave me error of it being private and cant be accessed.... ???
-
wrote on 9 Nov 2011, 20:17 last edited by
although the widgets, buttons do change position and size with respect to the parent dialog window
2/5