PDA

View Full Version : Creating multilevel tabs using qtcreator: How to do that?



robgeek
27th March 2015, 16:11
Hello!

I would like to know how can i create, using qtcreator, Tabs with more than one level in a QDialog. I have a QMainWindow and i put a button which, when clicked, opens a QDialog, another window, thats what i want. Inside this new window i want to put tabs with three levels, like the following picture(Attached), i made this in Java. I know, i have to use QTabWidget, but everytime i go(Insert Page->After Current Page) i create a new tab int the right, but i want a new one in bellow or above.

How can i do that?

robgeek
29th March 2015, 03:11
Guys, is there any other place where i can ask that? Maybe some other forum.

ChrisW67
29th March 2015, 03:18
The QTabWidget and QTabBar do not allow for that behaviour out-of-the box. When there are more tabs than will fit left-to-right you get scrolling controls on the end of the tab bar.

robgeek
29th March 2015, 06:11
Ok, thank you very much for your answer!

Kryzon
29th March 2015, 08:41
It should be possible to create a custom widget (also known as a "composite widget") that serves as a container and manager for several QTabBar widgets.

QTabBar is the lowest-level tab widget in Qt. It just serves to draw tabs and provide a simple interaction. I would look into making a custom widget that manages QTabBar children widgets and changes the level depending on the signals.
I would look in the source of QTabWidget to understand more how a QTabBar manager is like:
- https://qt.gitorious.org/qt/qtbase/source/6c06e14a49773ce5572935864ed6b9be219c6103:src/widgets/widgets/qtabwidget.h
- https://qt.gitorious.org/qt/qtbase/source/4cdff7a0ea95a881bba859157e6eb847f6c10dc5:src/widgets/widgets/qtabwidget.cpp

It doesn't have to be as complex as that since you won't implement a lot of generic features, but rather only what your application needs.
It should require an advanced understanding of how to subclass widgets to add custom functionality.
There's a basic example in ZetCode for a custom widget, but it's for Qt4 so it should be just a reference:
http://zetcode.com/gui/qt4/customwidget/