QDockWidget 可拖动标签

QDockWidget Draggable Tabs(QDockWidget 可拖动标签)
本文介绍了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 可拖动标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Rising edge interrupt triggering multiple times on STM32 Nucleo(在STM32 Nucleo上多次触发上升沿中断)
How to use va_list correctly in a sequence of wrapper functions calls?(如何在一系列包装函数调用中正确使用 va_list?)
OpenGL Perspective Projection Clipping Polygon with Vertex Outside Frustum = Wrong texture mapping?(OpenGL透视投影裁剪多边形,顶点在视锥外=错误的纹理映射?)
How does one properly deserialize a byte array back into an object in C++?(如何正确地将字节数组反序列化回 C++ 中的对象?)
What free tiniest flash file system could you advice for embedded system?(您可以为嵌入式系统推荐什么免费的最小闪存文件系统?)
Volatile member variables vs. volatile object?(易失性成员变量与易失性对象?)