如何在Qt中制作两行标签 [英] How can I make two rows of tabs in Qt
问题描述
我想要类似下图的内容.我想要两行标签.一个包含在另一个中.是使用两个QTabWidget的方法吗?另外,我想提到程序的主窗口将显示此结构.如果您有任何建议...
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).
图片http://imageshack.us/a/img831/3889/subtabs. png
推荐答案
使用嵌套的 QTabWidgets
:一个外部主选项卡,其中包含其自己的辅助QTabWidget(需要一个辅助QTabWidget).
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) :
-
查看如何使用嵌套的QTabWidgets处理 Qt样式表. 参见此答案以获取一些示例代码,当然,忘记QTabWidget,编写自己的QTabWidget,包含自定义标签栏,并使用 QStackedLayout 标签内容.您可以像使用QTabWidget一样嵌套这些自定义选项卡式窗口小部件,也可以只具有动态两行 一个非嵌套的自定义标签小部件中的标签栏,现在是您的代码.
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.
开始将QML用于UI,可能只是用于自定义选项卡栏,可能是整个中央窗口小部件,这取决于您在那里拥有什么.
Start using QML for UI, perhaps just for a custom tab bar, perhaps for the whole central widget, depending on what you have there.
这篇关于如何在Qt中制作两行标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!