How can I make two rows of tabs in Qt

ぐ巨炮叔叔 提交于 2019-12-25 04:58:10

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/15458256/how-can-i-make-two-rows-of-tabs-in-qt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!