PDA

View Full Version : QDockWidget Size



kiker99
7th February 2006, 19:57
Hallo,

i'm trying to convince a QDockWidget to resize itself to a proper size, but it alway takes away half of the window size. (at the bottom)

It would be perfect if the QDockWidget resized itself always in a certain relation to the total size of the Window (as 1/4).

I tried this, but it didn't help. A resize() also doesn't have any effect (I think because of the QLayout)

EDIT: think of setVerticalPolicy where there's setHorizontalPolicy down there. It doesn't make any sense in the other way. What do I need to set for SizePolicy if I want him to use VerticalStretch?



QSizePolicy sizePolicy2;
sizePolicy2.setVerticalStretch(3);
sizePolicy2.setHorizontalPolicy(QSizePolicy::Expan ding);
centralWidget2->setSizePolicy(sizePolicy2);
//chat erstellen
dockwidget=new QDockWidget(this);
dockwidget->setAllowedAreas(Qt::AllDockWidgetAreas);
addDockWidget(Qt::BottomDockWidgetArea, dockwidget);
chatwidget=new Chat(dockwidget);
dockwidget->setWidget(chatwidget);
QSizePolicy sizePolicy;
//sizePolicy.setHorizontalStretch(3);
sizePolicy.setHorizontalPolicy(QSizePolicy::Minimu m);
sizePolicy.setVerticalStretch(1);
dockwidget->setSizePolicy(sizePolicy);

Thanks,
Andre

kiker99
9th February 2006, 22:12
doesn't anbody have an idea? it'd be enough if I could set the QDockWidget's size (without changing maximumSize), for example with setGeometry.

jacek
9th February 2006, 22:29
Which Qt version do you use?

jh
12th February 2006, 13:23
hi,

i had the same problem. i couldn't figure out how to set the size of
a dockwidget explicitly because it's size is gouverned by the splitter
which handles the size of central widget and the dw. so as a workaround
i save the state of the window (QMainWindow::saveState()) and
restore the state on start up. if the user changes the size of
the dockwidget the size is at least the same the next time.
so only the first time the dw and central widget shares the size of
the mainwindow equaly.

jh

rianquinn
6th March 2006, 22:18
I am having the same problem. Although the suggested solution should work, this isn't a clean solution. Our customers don't want to have to resize everything on initail startup. I will put in a request to Trolltech to see if there is a better solution.

kiker99
11th March 2006, 17:30
Which Qt version do you use?

Qt4


I am having the same problem. Although the suggested solution should work, this isn't a clean solution. Our customers don't want to have to resize everything on initail startup. I will put in a request to Trolltech to see if there is a better solution.

thanks. You're right, this sucks.

Chicken Blood Machine
12th March 2006, 07:46
I am having the same problem. Although the suggested solution should work, this isn't a clean solution. Our customers don't want to have to resize everything on initail startup. I will put in a request to Trolltech to see if there is a better solution.

Here's what I would do (and have done in the past): Once you have arranged the dockwindow exactly how you want it to appear to the user, save the window state. You now have a string in the config file/registry that you can hardcode and use with loadState() to set the dockwindow size programmatically. You can now remove your load/save code and leave the hardcoded setting (or leave your load/save code in place as you wish).

rianquinn
21st March 2006, 22:21
Here's what I would do (and have done in the past): Once you have arranged the dockwindow exactly how you want it to appear to the user, save the window state. You now have a string in the config file/registry that you can hardcode and use with loadState() to set the dockwindow size programmatically. You can now remove your load/save code and leave the hardcoded setting (or leave your load/save code in place as you wish).

The problem with this idea is that our customers DON'T want to have to adjust the sizes, they want it a specific size at startup. We have strick requirements. This is known to be a bug, and will be fixed in version 4.2.

Chicken Blood Machine
21st March 2006, 22:40
The problem with this idea is that our customers DON'T want to have to adjust the sizes, they want it a specific size at startup. We have strick requirements. This is known to be a bug, and will be fixed in version 4.2.

I don't think you read what I wrote properly. My solution means that the customers don't have to adjust the size.

kiker99
31st March 2007, 17:15
Is this really fixed in >=4.2.0?
How to do it properly?