简体   繁体   English

在Qt Designer中创建选项卡式文档界面?

[英]Creating tabbed document interfaces in Qt Designer?

I am trying to write a program that will use a tabbed document interface (TDI) like seen in Notepad++ or most web browsers. 我正在尝试编写一个程序,该程序将使用选项卡式文档界面(TDI),如在Notepad ++或大多数Web浏览器中所见。 I know how to build GUIs using Qt Designer, and code in Qt C++ (after a few days of playing around). 我知道如何使用Qt Designer来构建GUI,以及如何在Qt C ++中构建代码(经过几天的尝试)。

I have created an example of what each page widget will look like using Designer, and now I want to add the ability to create and testroy tabs at runtime, each containing a unique instance of the page widget. 我已经创建了一个示例,说明使用Designer时每个页面小部件的外观,现在我想添加在运行时创建和测试选项卡的功能,每个选项卡都包含页面小部件的唯一实例。 However, I have no idea how to do this without adding a class that extends QWidget, and building the page widget with code. 但是,我不知道如何在不添加扩展QWidget的类并使用代码构建页面小部件的情况下执行此操作。 I could go down this route, but I'm sure there must be a better way of creating a TDI; 我可以走这条路,但是我确信必须有更好的创建TDI的方法。 but I can't find any tutorials or examples of how to do this. 但是我找不到任何教程或示例。

Does anyone have any suggestions? 有没有人有什么建议?

For creating tab interfaces you should look into QTabWidget . 要创建选项卡界面,您应该查看QTabWidget

It is a container widget included in Qt Designer which automatically handles operations on tabs. 它是Qt Designer中包含的容器小部件,可自动处理选项卡上的操作。 It has several build in methods for manipulating its tabs and theirs contents. 它具有几种用于处理选项卡及其内容的内置方法。

Each page of QTabWidget is handled separately and can have different layouts and functionality. QTabWidget的每个页面都是单独处理的,可以具有不同的布局和功能。

If you want to include several different objects to one page assign a layout to it and then assign the objects to the layout. 如果要在一个页面中包含多个不同的对象,请为其分配布局,然后将对象分配给该布局。

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

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