问题描述
我正在使用 QDockWidgets 并将其中两个放在我的应用程序的左侧,以便可以使用选项卡在它们之间进行选择.然而,Qt 的默认行为看起来很糟糕而且不直观.它不能拖动选项卡来移动小部件,而是在必须拖动的选定选项卡(具有相同名称)下方放置另一个栏.作为用户,很难弄清楚这一点.
I am using QDockWidgets and placing two of them on the left side of my application so that tabs can be used to select between them. However, Qt's default behavior for this looks horrible and is unintuitive. Instead of being able to drag the tabs to move the widgets, it places another bar below the selected tab (with the same name) that must be dragged instead. As a user, it would be hard to figure this out.
(我的 QDockWidgets 是属性"和库")
(My QDockWidgets are "Attributes" and "Library")
有没有办法摆脱第二个栏并制作它,以便我可以通过拖动标签本身来移动我的 QDockWidgets?
Is there a way to get rid of this second bar and make it so I can move my QDockWidgets by dragging the tabs themselves?
推荐答案
如果你将 QTabWidgets
添加到从 QMainWindow
派生的主窗口,你可以尝试 tabifyDockWidget
.它将两个 QDockWidgets
标记为您想要的,当然您也可以拖动它们.
If you are adding QTabWidgets
to a main window derived from QMainWindow
, you can try tabifyDockWidget
.
It tabifies two QDockWidgets
just like you wanted and of course you are able to drag them.
dockWidget1 = new QDockWidget("Tab1") ;
dockWidget2 = new QDockWidget("Tab2") ;
this->addDockWidget(Qt::LeftDockWidgetArea , dockWidget1 );
this->addDockWidget(Qt::LeftDockWidgetArea , dockWidget2 );
this->tabifyDockWidget(dockWidget1,dockWidget2);
这篇关于QDockWidget 可拖动标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!