Results 1 to 7 of 7

Thread: qdockwidget tabbed movable

  1. #1
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Exclamation qdockwidget tabbed movable

    Hi,
    When two (or more) docks are tabified it's not possible to move the tabs.
    Is it possible to make the tabs movable ? How ?
    Thanks

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qdockwidget tabbed movable

    Can you get a pointer to the tab widget? Call QTabWidget::setMovable() with the argument true.

  3. #3
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qdockwidget tabbed movable

    How get it since it's managed automatically by Qt when one dock is on another ?

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qdockwidget tabbed movable

    I do not see a QMainWindow method that will give you the tab widget for a QDockWidget (in fact, there isn't any method that will tell you if a particular dock widget is tabbed or not). There is no signal that will tell you when a QDockWidget has been tabbed or untabbed. There is a signal that tells you if a QDockWidget has been docked or undocked: QDockWidget::topLevelChanged() and a signal to tell you if it has been moved from one area to another.

    Try this: Add a slot to your MainWindow class and connect it to the topLevelChanged() signal for your dock widget. In the slot do something like this:

    Qt Code:
    1. void MainWindow::onTopLevelChanged( bool bFloating )
    2. {
    3. // If the window is *not* floating, then it is docked
    4. QDockWidget * pDock = qobject_cast< QDockWidget * >( sender() );
    5. if ( pDock && !bFloating )
    6. {
    7. // Determine if other widgets are docked with this one in a tab widget
    8. QList< QDockWidget * > buddies = tabifiedDockWidgets( pDock );
    9.  
    10. // If the list isn't empty, then the widget is part of a tab group
    11. if ( !buddies.empty() )
    12. {
    13. // Find the tab widget parent
    14. QTabWidget * pTab = 0;
    15. QWidget * pParent = pDock->parent();
    16. while ( pParent )
    17. {
    18. pTab = qobject_cast< QTabWidget * >( pParent );
    19. if ( pTab )
    20. break;
    21. pParent = pParent->parent();
    22. }
    23.  
    24. if ( pTab ) // We found it
    25. Ptab->setMovable( true );
    26. }
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 

    A few things I am not sure of:

    1 - I do not know if QMainWindow actually uses QTabWidget as the container when dock widgets are tabified.
    2 - I do not know if the container (QTabWidget or something else) is created and destroyed on-the-fly as dock widgets are tabified and un-tabified, or whether it is permanent and just hidden and shown as needed. This is why I wrote the code as shown - if the tab widget is dynamic, then it might change its pointer value.
    3 - I do not know if this code will work. It is your job to find out.
    Last edited by d_stranz; 26th June 2015 at 16:55.

  5. #5
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    Wiki edits
    7

    Default Re: qdockwidget tabbed movable

    According to the source and from experiments, the native docking system only uses QTabBars for displaying the dock pages.
    The docking system recycles its own QTabBars.

    Setting the movable property on an internal docking QTabBar and reordering its tabs by dragging them leads to a cyclic widget repaint error. It's not supported.

  6. The following user says thank you to Kryzon for this useful post:

    d_stranz (26th June 2015)

  7. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qdockwidget tabbed movable

    Bummer. Don't you just hate it when that happens?

  8. #7
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    Wiki edits
    7

    Default Re: qdockwidget tabbed movable

    I like to see how other Qt programs deal (or not) with this.
    Autodesk Maya, for example; it uses Qt and its native docking system, and the documentation doesn't mention tab reordering. But it's still a terrific program, so in the end it may not be something important.



    - http://knowledge.autodesk.com/suppor...rface-htm.html

Similar Threads

  1. Replies: 6
    Last Post: 27th August 2012, 23:44
  2. How to set focus (select) a tabbed QDockWidget?
    By serget in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2012, 16:40
  3. How can I know if a QDockWidget is tabbed?
    By ricardo in forum Qt Programming
    Replies: 1
    Last Post: 8th May 2009, 06:51
  4. Tabbed QDockWidget question
    By Khal Drogo in forum Qt Programming
    Replies: 1
    Last Post: 19th September 2008, 17:57
  5. QDockWidget Tabbed State
    By jtaylor108 in forum Newbie
    Replies: 2
    Last Post: 2nd August 2007, 00:16

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.