PDA

View Full Version : dockNestingEnabled



merlvingian
14th October 2006, 06:31
In 4.2 a very cool ability to nest dockwidget by setting
QMainWindow::dockNestingEnabled(true)
and moving docks over each other in the app will cause them to nest.

After looking through the docs I cannot find a way to nest dockwidgets in each other as a default state after creation. Anyone know if this is possible?

wysota
14th October 2006, 18:38
Could you elaborate on that? As I see this is a property of the main window and not of the dock widgets - you want to set them on the dock widgets?

merlvingian
14th October 2006, 22:05
Could you elaborate on that? As I see this is a property of the main window and not of the dock widgets - you want to set them on the dock widgets?

When QMainWindow::dockNestingEnabled() is set true it enables you to hover a dockwidget over another and nest one into the other. I would like to have the docks nested on creation, as it is now they have to be manually nested in runtime.

I cannot find any setting in a QDockWidget to have it nest another QDockWidget in itself on creation. Only references to nesting are found in QMainWindow.

wysota
15th October 2006, 00:08
Doesn't QMainWindow::addDockWidget() work?

merlvingian
15th October 2006, 01:06
Doesn't QMainWindow::addDockWidget() work?

No, if you use QMainWindow::addDockWidget() and give each widget lets say location Qt::BottomDockWidgetArea it will pair up the 2 dockwidgets, not nest them inside each other.

If you child a QDockWidget from another on creation and give the same area it also does not produce the desired result of nested docks. I am sure it is something simple I am missing.

tanminh
26th February 2008, 23:18
This issue was asked a while ago but I don't see it addressed to resolution, so I'm posting just in case someone is looking for an answer. The approach is rather simple if you read Qt documentation carefully. It seems counter-intuitive but it works. The following sample will nest 4 dockwidgets in the order A, B, C, D after they are created. The bottom dock area is used.


addDockWidget(Qt::BottomDockWidgetArea, DockWidget_A);
addDockWidget(Qt::BottomDockWidgetArea, DockWidget_B;
addDockWidget(Qt::BottomDockWidgetArea, DockWidget_C);
addDockWidget(Qt::BottomDockWidgetArea, DockWidget_D);

//Put DockWidget_A and DockWidget_B each in its own tab.
tabifyDockWidget(DockWidget_A, DockWidget_B);
//Now that DockWidget_B is in a tab, achieve the effect of adding a tab by
//calling splitDockWidget(). A new tab is added because the tab that contains
//DockWidget_B can only have one dock widget, thus a tab for DockWidget_C
//must necessarily be created.
splitDockWidget(DockWidget_B, DockWidget_C, Qt::Horizontal);
//Repeat the above step to add a tab for DockWidget_D.
splitDockWidget(DockWidget_C, DockWidget_D, Qt::Horizontal);

merlvingian
27th February 2008, 08:16
This question was originally asked before QMainWindow::tabifyDockWidget was added to the API.

But thank you for appending the post to clarify it's use now that it has been implemented.

Mehran
5th March 2008, 19:56
Hi I am new to QT development. I have been trying to use tabifyDockWidget() in order to get my 2 dock widgets to come up as tabbed on the start of my application. I have tried what was told at the beginning of this thread but the Dock Widgets created go on top left corner of my main Window under the main menu.

I am using QT 4.2.2. Can some one send me a real example the shows how I can make two dock widgets to come up as tabbed from the start of my application?

Following is my sample code:


m_sysNavigator = new QDockWidget("System Navigator", this);
m_sysNavigator->setAllowedAreas(Qt::LeftDockWidgetArea |
Qt::RightDockWidgetArea);
addDockWidget(Qt::LeftDockWidgetArea, m_sysNavigator);

m_recViewDock = new QDockWidget("Recording", this);
m_recViewDock->setAllowedAreas(Qt::LeftDockWidgetArea |
Qt::RightDockWidgetArea);
addDockWidget(Qt::LeftDockWidgetArea, m_recViewDock);
tabifyDockWidget(m_sysNavigator,m_recViewDock);

Thank you for your help.

BadHare
17th June 2009, 23:54
Is it possible to programmatically choose which one of the tabbed docks should become active (be brought to top)?

I have a "Navigator" window, in which I select which of the "client" windows I want to open. These are wrapped in a QDockWidget and added to main window using the addDockWidget and tabifyDockWidget (on the last added dock). Adding a new client works fine. But, imagine I have just opened two clients: A and B. This created two docks, which are placed in their corresponding tabs. If I click on A again, I would like the tab containing window A to be selected.

Any ideas on how to do this? Perhaps if we had access to the private QDockAreaLayout inside QMailWindow, this might be easier?...

Thanks in advance,

BH

jacmoe
18th June 2009, 21:46
Call raise() on the one you want at the top.:)

BadHare
19th June 2009, 18:33
Call raise() on the one you want at the top.:)

That worked! Thanks for your help!

Earlier I tried calling raise() on the client window, which is contained inside of the QDockWidget (http://doc.trolltech.com/latest/qdockwidget.html), but - obviously - that did not work. Calling raise() on the dock widget itself, as you suggested, did the trick!

Thanks again! :)