PDA

View Full Version : I want to add something that looks like a QGridLayout to a QDockWidget with setWidget



gQt
24th August 2009, 11:59
Hi all,

Unfortunately it's not possible to add a QGridLayout* to a QDockWidget in a QMainWindow. It is possible to add one QLineEdit or one QLabel with QDockWidget::setWidget(QWidget *widget).

It's possible to add a QTextEdit which is able to show file contens to the DockWidget with setWidget, but then I have to write all the QLinEdit/QLabels to file which is inconvenient since the QLineEdits variables will change a lot of times during program execution.

My question is how can I add several QLineEdit/QLabels to the same DockWidgetArea?
Any help is deeply appreciated!
Thanks

victor.fernandez
24th August 2009, 12:27
Can't you just create a blank widget, set it as the dockwidget's widget and then assign it the layout you want?



QWidget *widget = new QWidget(this);
dockWidget->setWidget(widget);

QGridLayout *layout = new QGridLayout(widget);
// add widgets to the layout

gQt
24th August 2009, 12:40
That worked :D
Thanks, That blank widget solved the problem!