Results 1 to 11 of 11

Thread: dockNestingEnabled

  1. #1
    Join Date
    Sep 2006
    Posts
    46
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default dockNestingEnabled

    In 4.2 a very cool ability to nest dockwidget by setting
    Qt Code:
    1. QMainWindow::dockNestingEnabled(true)
    To copy to clipboard, switch view to plain text mode 
    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dockNestingEnabled

    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?

  3. #3
    Join Date
    Sep 2006
    Posts
    46
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dockNestingEnabled

    Quote Originally Posted by wysota View Post
    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: dockNestingEnabled


  5. #5
    Join Date
    Sep 2006
    Posts
    46
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dockNestingEnabled

    Quote Originally Posted by wysota View Post
    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.
    Last edited by merlvingian; 15th October 2006 at 01:09. Reason: Added hot link references

  6. #6
    Join Date
    May 2006
    Posts
    7
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: dockNestingEnabled

    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.

    Qt Code:
    1. addDockWidget(Qt::BottomDockWidgetArea, DockWidget_A);
    2. addDockWidget(Qt::BottomDockWidgetArea, DockWidget_B;
    3. addDockWidget(Qt::BottomDockWidgetArea, DockWidget_C);
    4. addDockWidget(Qt::BottomDockWidgetArea, DockWidget_D);
    5.  
    6. //Put DockWidget_A and DockWidget_B each in its own tab.
    7. tabifyDockWidget(DockWidget_A, DockWidget_B);
    8. //Now that DockWidget_B is in a tab, achieve the effect of adding a tab by
    9. //calling splitDockWidget(). A new tab is added because the tab that contains
    10. //DockWidget_B can only have one dock widget, thus a tab for DockWidget_C
    11. //must necessarily be created.
    12. splitDockWidget(DockWidget_B, DockWidget_C, Qt::Horizontal);
    13. //Repeat the above step to add a tab for DockWidget_D.
    14. splitDockWidget(DockWidget_C, DockWidget_D, Qt::Horizontal);
    To copy to clipboard, switch view to plain text mode 

  7. The following 2 users say thank you to tanminh for this useful post:

    BadHare (17th June 2009), ravas (8th September 2015)

  8. #7
    Join Date
    Sep 2006
    Posts
    46
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dockNestingEnabled

    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.
    Last edited by merlvingian; 27th February 2008 at 08:20. Reason: not typo changed to now; bah more typos

  9. #8
    Join Date
    Mar 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: dockNestingEnabled

    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:
    Qt Code:
    1. m_sysNavigator = new QDockWidget("System Navigator", this);
    2. m_sysNavigator->setAllowedAreas(Qt::LeftDockWidgetArea |
    3. Qt::RightDockWidgetArea);
    4. addDockWidget(Qt::LeftDockWidgetArea, m_sysNavigator);
    5.  
    6. m_recViewDock = new QDockWidget("Recording", this);
    7. m_recViewDock->setAllowedAreas(Qt::LeftDockWidgetArea |
    8. Qt::RightDockWidgetArea);
    9. addDockWidget(Qt::LeftDockWidgetArea, m_recViewDock);
    10. tabifyDockWidget(m_sysNavigator,m_recViewDock);
    To copy to clipboard, switch view to plain text mode 

    Thank you for your help.
    Last edited by jpn; 5th March 2008 at 19:59. Reason: missing [code] tags

  10. #9
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dockNestingEnabled

    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

  11. #10
    Join Date
    Jun 2009
    Posts
    5
    Thanks
    1
    Thanked 2 Times in 1 Post
    Platforms
    Unix/X11 Windows

    Default Re: dockNestingEnabled

    Call raise() on the one you want at the top.

  12. The following 2 users say thank you to jacmoe for this useful post:

    BadHare (19th June 2009), ravas (8th September 2015)

  13. #11
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: dockNestingEnabled

    Quote Originally Posted by jacmoe View Post
    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, but - obviously - that did not work. Calling raise() on the dock widget itself, as you suggested, did the trick!

    Thanks again!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.