How can I make two rows of tabs in Qt

2019-08-31 05:59发布

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

2条回答
等我变得足够好
2楼-- · 2019-08-31 06:40

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.

查看更多
聊天终结者
3楼-- · 2019-08-31 06:52

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.

查看更多
登录 后发表回答