如何将QDockWidgets停靠在QSplitter中? [英] How to dock a QDockWidgets inside a QSplitter?

查看:339
本文介绍了如何将QDockWidgets停靠在QSplitter中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让QSplitter在我的应用程序中接受QDockWidgets.到目前为止,我已经通过Qt设计器完成了所有工作,而我要做的是创建三个单独的QWidget.然后,我选择所有三个QWidget,然后右键单击它们,然后选择布局"->在拆分器中垂直放置".

I am trying to have a QSplitter accept QDockWidgets in my application. So far, I have done everything through the Qt Designer and what I have done is create three individual QWidgets. I then select all three of the QWidgets and I right click on them and select Layout->Lay out Vertically in a Splitter.

这将所有三个小部件很好地放置在一个拆分器中.然后,我将Dock窗口小部件拖到右上角的对象/类"窗口中,并在Splitters窗口小部件中进行设置.这样可以将QDockWidget愉快地放置在小部件内.但是,当我启动程序时,无法单击并拖动停靠窗口小部件.如果我双击停靠小部件,则会弹出停靠小部件,但是由于技术上从未停靠,所以无法放回它.这就造成了小部件不能停靠在其他任何地方的问题.它不能停靠在QMainWindow类或QSplitter类上.

This lays all three of the widgets in a splitter quite nicely. I then drag a Dock Widget to the Object/Class Window in the top right and set them in the Splitters Widget. This places the QDockWidget happily inside the widget. However, when I fire up the program I cannot click and drag the dock widgets. If I double click the dock widget, the dock widget will pop out, however I cannot place it back since it was never technically docked. Which then creates the problem of the widget not being allowed to dock anywhere else. It cannot be docked on the QMainWindow class or in the QSplitter class.

反正有QDockWidget停靠在QSplitter内部并且具有QDockWidget的功能吗?

Is there anyway to have a QDockWidget docked inside of a QSplitter and have the functionality of a QDockWidget?

推荐答案

在将停靠小部件添加到QSplitter之后,该小部件已成为拆分器的一部分.

After you add the dock widget to the QSplitter, the widget has become part of the splitter.

您可以尝试这样检查

//If sure of Dockwidget at zeroth position
QDockWidget *widget1 = (QDockWidget*)ui->splitter->children().at(0);

Dockwidget具有作为顶部窗口浮动的功能. 但是您可以通过设置QDockWidget::NoDockWidgetFeatures

A Dockwidget has a feature of floating as a top level window. But you can make a dockwidget look like other widgets by setting QDockWidget::NoDockWidgetFeatures

要么:

转到Qtdesigner中的对象窗口(顶部->右侧) 然后选择添加到拆分器的停靠小部件.

Go to the object window in Qtdesigner (top -> right) And select the dock widget added to splitter.

在属性窗口中,向下滚动至下方并查找功能".

In proeprties window, down below scroll down and look for "features".

然后取消选中可移动,可关闭等功能. 我将其设置为NoDockWidgetFeatures.

Then uncheck the features like movalble, closable etc.... I made it NoDockWidgetFeatures.

您可以使用setFeatures(QDockWidget::NoDockWidgetFeatures)

这篇关于如何将QDockWidgets停靠在QSplitter中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆