Momergil
Momergil

Reputation: 2281

How can I create a system similar to QDockWidget but for tabs?

I had an idea I have no clue on how to implement. I'm working with Qt and I'ld like to have a system of tabs that allows me to use tabs in the same way one can use QDockWidgets, that is: with QDockWidgets one can pick a widget and use it floating around the monitor or he can dock it in a QMainWindow in any of the four sides. Well I would like to have such attribute with a QTabWidget! So suppose I have two QTabWidgets in front of me. With the proposed idea, I would be capable to drag and drop a tab (with its widget) from one QTabWidget to another or even simply undock it from its original QTabWidget and start using it independently as another QTabWidget with one tab.

Well I couldn't find a way to use QTabWidget this way "naturally"; it seems Qt doesn't provide such possibility with its pack of widget classes. So does anybody knows any project open to the public containing a class able to do such thing? Or how could I implement such a new class myself? (I don't know for example how could I make the drag and drop effect from a QTabBar since even if setMovable is set to true, still isn't possible to make the tab go away from area of the QTabBar.

Any help will be appreciated.

Upvotes: 0

Views: 1590

Answers (1)

Max Go
Max Go

Reputation: 2102

QDockWidgets already provide possibility to be tabbed. You can check Dock Widgets Qt sample project in Main Windows section. Screen of the just launched sample app: enter image description here

Screen of the tabbed doc widgets: enter image description here

Check this answer for implementation details.

Upvotes: 2

Related Questions