View Full Version : QDockWidget nesting problem..

29th January 2007, 06:14
I have a main window and two dock widgets. When I nest one dock widget over the other, the widget inside them appear to draw on the parent, even though it is not desired. I found this problem related to setting the setMinimumSize on dock widgets. If u set the minimumsize and nest / overlap the dock widget, the widget that should be drawn is drawn. I am attaching an example showing the problem

I also tried with the dock widget example in Qt Demos, and upon setting the minimum size say setMinimumSize(200,200), that example also behaves abnormally.

Is this a bug ?

29th January 2007, 11:49
nebody to help ??
thers no problem if i remove the setMinimumSize() function. So is this a bug ??

31st January 2007, 10:10
:confused: :confused: :confused:


31st January 2007, 12:00
use SizeHint to set initial size and use minimumSizeHint() for set minimum size.

for eg:
replace your code to
MyDockWidget *dock1 = new MyDockWidget("dock 1");
see attachment.

class MyDockWidget : public QDockWidget
MyDockWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0)
:QDockWidget(title,parent, flags)
szHint = QSize(-1, -1); // for initial size
minSzHint = QSize(100, 100); // for minimum size
virtual QSize sizeHint() const
return szHint;
virtual QSize minimumSizeHint() const
return minSzHint;
QSize szHint, minSzHint;

31st January 2007, 12:02
you can nest / overlap the dock widget by code also.
tabifyDockWidget(dock1, dock2);

31st January 2007, 12:33
Thanx for the reply, but it doesnt help :(

already mentioned in the first post, that the problem occurs due to setting setMinimumSize. If setMinimumSize is not set, it works witout the size hint too.

As for the size hint, it written in the docs...
If minimumSize() is set, the minimum size hint will be ignored.

So your solution deosnt work.
Try setting minimum size for docking widget example. It will behave abnormally

I just wanted to know if this abnormal behaviour is a bug ??

31st January 2007, 13:23
sometime back I got the same problem, So I removed setMinimumSize() and added minimumSizeHint() to fix minimum size.
it may be bug, you need to report trolltech(support@trolltech.com) to create bug report.
I have created some bug report releted to QDockWidget. you can track this
http://www.trolltech.com/customer/task-tracker (http://www.trolltech.com/customer/task-tracker) with task id 145881

Thanks & Regards