本文介绍了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可拖动选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-27 07:52