PDA

View Full Version : resize a docked QDockWidget programmatically



ArkKup
6th August 2012, 17:41
Hi,

is there any way to resize a docked QDockWidget programmatically ? I have three dock windows one on the left side, one on the right side and one at the bottom.
I'd like to make the bottom window smaller in height since is contains only log information



dock = new QDockWidget(tr("bottomDock"), this);
dock->setAllowedAreas(Qt::AllDockWidgetAreas);
QPlainTextEdit *logEdit = new QPlainTextEdit(dock);
dock->setWidget(logEdit);
dock->resize(200,200); //not working
addDockWidget(Qt::BottomDockWidgetArea, dock);


I have tried calling resize() on the logEdit but no luck.
The only way to make it work I found is to use setMaximumHeight on logEdit but I don't like that solution.

Anybody knows more appropriate solution to this problem ?

high_flyer
7th August 2012, 09:08
The dock widgets size is managed by the QMainWindow layout - so forcing the widget to a max height is probably your only simple way to do it.

ArkKup
7th August 2012, 09:58
OK thanks. if there is no simple solution can anyone recommend more advance solution to this problem ? that I could try

high_flyer
7th August 2012, 14:24
You could subclass QLayout and set it as your QMainWindow layout.

vkn
10th August 2012, 07:43
I am facing the same problem. I too need to resize a docked QDockWidget programmatically (change it's width on some user action).

Can I have some sample example code for using layout for QDockWidget (advance solution to this problem) by which you think we may be able to resize the docked QDockWidget programmatically.

Thanks.