Question

I would like to have something like the following image. I want two rows of tabs. One is included in the other. Is using two QTabWidget the way to go? Also, I would like to mention that the program's main window will display this structure. If you have any suggestions...

I would like the tabs to look like the following (of course, not exactly; this handmade image is awful).

Image http://imageshack.us/a/img831/3889/subtabs.png

Was it helpful?

Solution

Use nested QTabWidgets: an outer primary tab which contains its own secondary QTabWidget (where one is necessary).


Since you are after specific look, then there are three possible solutions (ordered by complexity) :

  1. See what you can do with Qt style sheets using nested QTabWidgets. See this answer for some example code, and of course reference in docs.

  2. Forget QTabWidget, write your own, containing custom tab bar, and using a QStackedWidget or just nested QStackedLayout for tab contents. You can nest these custom tabbed widgets like you would with QTabWidget, or just have dynamic two-row tab bar in one non-nested custom tab widget, it's your code now.

  3. Start using QML for UI, perhaps just for a custom tab bar, perhaps for the whole central widget, depending on what you have there.

OTHER TIPS

You can use QTabBar instead. A QTabWidget is formed from a QStackedWidget and a QTabBar, but you can use QTabBars directly - and have two or three or more layers of tabs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top