PDA

View Full Version : Problem while Docking/Undocking of the QDockWidget on the default mainwindow "Central



pastispast
28th November 2010, 16:20
Hi Friends,

I am facing the problem while Docking/Undocking of the QDockWidget on the default mainwindow "CentralWidget". I am using method "setCentralWidget()" to setting the dockwidget on the main window.

But when I dock it and trying to undock again then it does not worked.

Is there any known way to deal with this problem?

Note: I have tried to set the float behavior using mouse double click as:

setFloating(false) &
setCentralWidget(...);

But it doesn't work.

I have attached my example along with this post.

Thanks...

franz
28th November 2010, 19:17
Dock widgets are meant to be used around the central widget. Your implementation more or less asks for quirky behavior... What behavior do you want to achieve? Try to explain without mentioning dock windows. Just make some screen shots and choose a few easy-to-type-about names to clarify. Maybe someone can offer you a better solution to what you're trying to achieve.

stefanadelbert
29th November 2010, 02:50
I imagine what you'd want to do is call setCentralWidget and pass in the child widget of the QDockWidget. As franz says, QDockWidgets occupy the space around the QMainWindow's central widget. I could understand that you'd want to use a widget contained in a QDockWidget as the central widget, but you'd then need to do something with the widget that is already being used as the central widget and you'd need to do something with QDockWidget that used to contain the widget that is now the central widget.

Things to remember is that a QMainWindow always needs to have a central Widget.

If you've got multiple widgets that could occupy the MainWindow's central widget area, then maybe your central widget should rather be a QTabWidget which could then contain multiple "central" widgets. You could then add functionality that removes a widget from the QTabWidget and puts it in a floating QDialog and vice versa. No reason why you couldn't also remove a widget from the QTabWidget and put it in a floating QDockWidget and vice versa, but then you wouldn't really be using a QDockWidget as intended.

Might also be worthwhile looking into a MDI interface (see QMdiArea).

A few random ideas, but I've got myself thinking now. I'll need to do something along these lines with my app at some point soon. I'll get back if I come up with anything that works nicely.

pastispast
29th November 2010, 15:48
Dock widgets are meant to be used around the central widget. Your implementation more or less asks for quirky behavior... What behavior do you want to achieve? Try to explain without mentioning dock windows. Just make some screen shots and choose a few easy-to-type-about names to clarify. Maybe someone can offer you a better solution to what you're trying to achieve.

Thanks franz...

Actually I have problem regarding to the positioning of the QDockWidget on the QMainWindow. I have 3 dockwidget in my main window [initially centre widget I put as 0]:

maindock: left side
rightdock: right side
bottomdock: bottom side

I have to position the dockwidget in some ratio (Say 3/4 width for maindock, 1/4 width for left dock and 100 px height for bottom widget).

Now I want that when I close the "rightdock" and "bottomdock", then "maindock" should take the place of others, but reverse should not possible(i.e. when close "maindock" then "rightdock" and "bottomdock" should not resize). All the dockwidgets
should have the docking features.

To achieve this I have used the approach that I have mention in my initial post (i.e. if maindock will be member of the centre
widget then I can achieve this, but the problem comes here...)

franz
29th November 2010, 17:06
So basically you want rightdock and bottomdock to be fixed size, and maindock to be expanding?

pastispast
30th November 2010, 07:40
So basically you want rightdock and bottomdock to be fixed size, and maindock to be expanding?

Hi franz thanks for the reply...Actually I don't want that "rightdock" and "bottomdock" to be fixed size but it can be re-size by the user, but automatic they should not dock when maindock close(As dock feature). But both should have dock effects(like float etc...).