QDockWidget Draggable Tabs(QDockWidget 可拖动标签)
问题描述
我正在使用 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 可拖动标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:QDockWidget 可拖动标签
基础教程推荐
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- CString 到 char* 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
