PDA

View Full Version : QDockWidget + QTabBar, but tabs don't move



NIteLordz
2nd January 2015, 02:32
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.



QList<QTabBar *> tabList = findChildren<QTabBar *>();

QTabBar* sceneGameTabBar = tabList.at(0);
sceneGameTabBar->setCurrentIndex(0);
sceneGameTabBar->setMovable(true);

d_stranz
2nd January 2015, 19:20
What happens if you try to move the tab through code? QTabBar::moveTab()

NIteLordz
2nd January 2015, 20:11
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.

d_stranz
2nd January 2015, 22:33
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.

NIteLordz
2nd January 2015, 22:49
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.

Kryzon
4th January 2015, 00:00
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/source/25d972e12eda9dadf212d24af8d8f524572bdbfa:src/gui/widgets

NIteLordz
4th January 2015, 00:11
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

Kryzon
4th January 2015, 00:26
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.

NIteLordz
4th January 2015, 01:37
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

Kryzon
4th January 2015, 03:08
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.

NIteLordz
4th January 2015, 03:10
Definitely not an urgent matter. Let me know if I can help in anyway.

Kryzon
22nd January 2015, 18:06
For cross-referencing, here's the thread:
http://www.qtcentre.org/threads/61403-SOLVED-Detachable-QDockWidget-tabs