简体   繁体   English

使标签在Qt中移动

[英]Make tabs movable in Qt

I want to make an application in Qt where the tabs in the QTabBar can be "undocked" so they will become a floating window, or can be dragged into another QTabBar and "transfer" into that QTabBar. 我想在Qt中创建一个应用程序,其中QTabBar中的选项卡可以“取消停靠”,因此它们将成为一个浮动窗口,或者可以拖入另一个QTabBar并“转移”到该QTabBar中。 My aim is to let the user completely customize the interface by dragging modules around into each other. 我的目标是让用户通过相互拖动模块来完全自定义界面。

If you have ever used Adobe After Effects CS5, it has the exact effect I'm looking for. 如果您曾经使用过Adobe After Effects CS5,它具有我正在寻找的确切效果。 It allows you to drag a tab and make it float as it's own window, dock it into another tab page and do a lot more. 它允许您拖动选项卡并使其浮动为其自己的窗口,将其停靠到另一个选项卡页面并执行更多操作。

So, if anyone could point me in the right direction on how to go about this, or even where I would begin that would be great! 所以,如果有人能指出我如何解决这个问题的正确方向,或者甚至在我开始的那个方面会很棒!

Take a look to the Qt Main Window Demo it uses QDockWidget rather than QTabBar's. 看看它使用QDockWidget而不是QTabBar的Qt主窗口演示 This example should be included the QTDIR/demos/ folder of your Qt installation. 此示例应包含在Qt安装的QTDIR / demos /文件夹中。

You will see that there are no tabs in the window, but try to drag some dock and drop it over another dock an you will see that a tabbar is created. 您将看到窗口中没有选项卡,但尝试拖动某个停靠点并将其拖放到另一个停靠栏上,您将看到创建了一个标签栏。 Also the docks can be floating around the desktop. 码头也可以在桌面上浮动。 This behavior is provided by Qt and it can be enabled or disabled with just set some flags for the docks. 此行为由Qt提供,只需为Dock设置一些标志即可启用或禁用它。 Check the code for more details. 检查代码以获取更多详细信息。

I hope that this was what you're were looking for. 我希望这就是你正在寻找的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM