PDA

View Full Version : Using QDockWidget in a QFrame



Polnareff
31st May 2010, 19:37
Hi,

I've noticed that the QDockWidget can only actually be docked within a MainWindow. I'd like to be able to have one which docks only within a QFrame. Is this possible, and why exactly does it have this behaviour?

tbscope
31st May 2010, 20:01
A QMainWindow has the docking infrastructure, a QFrame does not.
So, no you can't use a QDockWidget in the same way in a QFrame as you do in a QMainWindow.

Why do you want dock widgets in a frame?

Polnareff
31st May 2010, 21:09
The problem lies in not being able to nest QMainWindows (assuming I'm not wrong about that). What I have is a mainwindow with different perspectives, switched via checkable toolbar buttons. The perspective change only alters everything below the toolbar, essentially loading almost an entire new part of the software. As a result, it's as if each of these perspectives is its own MainWindow, without its own toolbars. But since I can't just place a MainWindow within another, I use a QFrame.

This problem at hand is actually a bit more complicated, since I want my DockableWidget to reside in another QFrame nested in the one I spoke of above. Essentially, I have something resembling the following:

http://img714.imageshack.us/img714/3531/screenfn.jpg

Everything below the toolbar is within a QFrame. And the right side of the treeview is actually another QFrame. As you can see, in that frame is where I want the QDockWidget to be.

aamer4yu
1st June 2010, 06:47
You might need to do some clever hack for dock widget drag and drop.. you can extract the widget from QDockWidget and set it as a child of QFrame..
then on drag event, you can again set the widget as child of QDockWidget.....

it might not be easy,,, but thats what came to my mind :D

Polnareff
1st June 2010, 14:50
You might need to do some clever hack for dock widget drag and drop.. you can extract the widget from QDockWidget and set it as a child of QFrame..
then on drag event, you can again set the widget as child of QDockWidget.....

it might not be easy,,, but thats what came to my mind :D
Ooohh...I like the idea. I'll give it a shot.

It still surprises me, though, that the library is like this. Has no one else ever wanted to use a QDockWidget in something nested within their QMainFrame?

CeeKey
1st June 2010, 15:25
Ooohh...I like the idea. I'll give it a shot.

It still surprises me, though, that the library is like this. Has no one else ever wanted to use a QDockWidget in something nested within their QMainFrame?

Im curious about it! I've tried the same, but i found no "look and feel" solution to put the dockwidget back into the widget or in your case the frame. However, why didnt you nest your mainwindow into a widget and this widget into the mainwindow?

Polnareff
1st June 2010, 15:42
Can you nest a mainwindow? Cuz as far as I know, each time I try it just creates it as a new dialog. Otherwise I wouldn't have a problem. I guess I'll give it another shot...

CeeKey
1st June 2010, 16:11
I can't try it out atm, but I'm pretty shure. Maybe



setWindowFlags(Qt::Widget);

will help?!

Polnareff
1st June 2010, 19:59
That worked! It was so simple :P Thanks a bunch!