Results 1 to 12 of 12

Thread: QDockWidget + QTabBar, but tabs don't move

  1. #1
    Join Date
    Dec 2014
    Posts
    49
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5 PyQt3 PyQt4
    Platforms
    Windows

    Default QDockWidget + QTabBar, but tabs don't move

    I have two QDockWidgets that occupy the same dock area. I call tabifyDockWidget(widgetX, widgetY), and this then produces two tabs inside of a QTabBar. When i query for the tab bars, i receive a pointer to the tab bar. i verified by setting current index to both values, and had expected results.

    however, if i call setMovable(true), the tabs are not movable back and forth.

    Is this a side of using a dockwidget to create the tab bar, or do i need to enable another member.

    Qt Code:
    1. QList<QTabBar *> tabList = findChildren<QTabBar *>();
    2.  
    3. QTabBar* sceneGameTabBar = tabList.at(0);
    4. sceneGameTabBar->setCurrentIndex(0);
    5. sceneGameTabBar->setMovable(true);
    To copy to clipboard, switch view to plain text mode 

  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 + QTabBar, but tabs don't move

    What happens if you try to move the tab through code? QTabBar::moveTab()

  3. #3
    Join Date
    Dec 2014
    Posts
    49
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5 PyQt3 PyQt4
    Platforms
    Windows

    Default Re: QDockWidget + QTabBar, but tabs don't move

    They don't move. It seems the only method that affects the tab bar is setCurrentIndex(int). None of the other methods seem to affect it.

  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 + QTabBar, but tabs don't move

    That's odd. Maybe the underlying implementation is a private class derived from QTabBar which overrides some of the methods and behavior. I don't think there is anything else you need to do to get movable tabs. Maybe a little test app is called for here - make a UI with a normal QTabWidget as the central widget, add some tabs to it, and see what it takes to get them movable.

  5. #5
    Join Date
    Dec 2014
    Posts
    49
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5 PyQt3 PyQt4
    Platforms
    Windows

    Default Re: QDockWidget + QTabBar, but tabs don't move

    We think alike. I used the sample Color Swatches from Qt samples, and it does not provide movable tabs either.

    If i create a tab widget within my dock widget, and supply multiple tabs, and setMovable(true), then they can be moved around easily. It is the only flag that needs to be set. So i am thinking something is being swallowed under the hood. The more i find little nuances like this, the more i am thinking i need to extend the DockWidget class, and provide some internal overrides. not looking forward to that though.

  6. #6
    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 + QTabBar, but tabs don't move

    What platform are you using?
    I'm also playing around with QDockWidget tabs with Windows XP, Qt 5.3.2, and when I setMovable( true ), it does work, I can grab and reorder the tabs.
    But then the tab names start swapping around and eventually the application crashes with "QWidget::repaint Recursive repaint detected."
    I just set the movable property, I don't force the current index.

    I don't think movable tabs are possible with the dynamic QTabBars created from the dock widget layout system, as it is. Their painting must do something out of the ordinary.
    If you could manage to at least relocate dock tabs through code (if not by moving tabs, then by some other means like hiding\unhiding, retabifying etc.), you could then install an event filter on the tab bar and have a "snappy," non animated tag dragging by processing tab mouse events and dragging yourself. I'm using this to achieve detachable dock tabs.

    In any case, you should also try to read the source of qdockwidget.cpp and qdockarealayout.cpp to see if there's anything that can be done without tampering with the source:
    https://qt.gitorious.org/qt/qt/sourc...rc/gui/widgets
    Last edited by Kryzon; 4th January 2015 at 00:18.

  7. #7
    Join Date
    Dec 2014
    Posts
    49
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5 PyQt3 PyQt4
    Platforms
    Windows

    Default Re: QDockWidget + QTabBar, but tabs don't move

    I'm working on Windows 8.1. so on windows xp you are able to get the two dockwidgets to tabify, and set movable, and have them move? sorry, am confused but your two paragraphs, as the dockwidgets create a dynamic tab bar.

    thanks much for input though

  8. #8
    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 + QTabBar, but tabs don't move

    I don't tabify them through code, I drag one dock on top of the other, while the program is running, and drop it. They become tabified.
    In my subclassed dock widget I have a slot receiving its own signal topLevelChanged( bool topLevel ), and in this slot I identify the tab bar that is now holding this dock widget and set its setMovable( true ).

    With this the tabs are movable with the mouse, but they crash the program consistently. I don't think it's something possible to have.
    Toon Boom, a commercial, industry standard animation software that uses Qt has detachable dock tabs but not movable tabs.

  9. #9
    Join Date
    Dec 2014
    Posts
    49
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5 PyQt3 PyQt4
    Platforms
    Windows

    Default Re: QDockWidget + QTabBar, but tabs don't move

    My next phase is to subclass the dock widget. I want to get rid of the title bar ugliness and have tabs displayed fulltime, ala unity editor.

    Could u post the snippet you're using for the top level, am curious, and without having code in front of me at the moment, its bugging me lol.

    Thanks much

  10. #10
    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 + QTabBar, but tabs don't move

    Do you need this with urgency? I want to finish this detachable dock tab behaviour, and if it actually works, I'll pack it in an example project and share around here for others like me that are looking for this functionality.

  11. #11
    Join Date
    Dec 2014
    Posts
    49
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5 PyQt3 PyQt4
    Platforms
    Windows

    Default Re: QDockWidget + QTabBar, but tabs don't move

    Definitely not an urgent matter. Let me know if I can help in anyway.

  12. #12
    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 + QTabBar, but tabs don't move

    For cross-referencing, here's the thread:
    http://www.qtcentre.org/threads/6140...ockWidget-tabs

Similar Threads

  1. movable QTabBar or QTabWidget set some tabs fixed
    By fsmoke in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2014, 02:24
  2. Replies: 1
    Last Post: 8th January 2012, 23:37
  3. Replies: 0
    Last Post: 17th November 2011, 12:51
  4. QTabBar make all tabs out of focus
    By migel in forum Newbie
    Replies: 1
    Last Post: 24th August 2011, 13:38
  5. QTabBar color in space inbetween tabs
    By AwDogsgo2Heaven in forum Newbie
    Replies: 1
    Last Post: 12th March 2010, 09:44

Tags for this Thread

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.