【发布时间】:2020-03-02 00:51:31
【问题描述】:
我想要一个QTabWidget,其中包含一个包含自定义小部件的选项卡。
-
我创建了一个自定义小部件(由 .ui、.h 和 .cpp 文件组成)
-
我在
QTabWidget的首页添加了这个自定义的Widget,但是QtCreator的设计器中没有显示这个Widget的内容。 -
我将我的自定义小部件推广为
Tab1Custom。
当我运行程序时,此设置编译并按预期工作,但我的自定义控件没有显示在 QtCreator 的设计器中。
如何使我的自定义控件显示在 QtCreator 的设计器中?
这是 MainWindow.ui 的第一部分:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>my title </string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>10</y>
<width>801</width>
<height>551</height>
</rect>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="Tab1Custom" name="myTab1">
<attribute name="title">
<string>My Tab number 1</string>
</attribute>
</widget>
....
【问题讨论】:
-
QtCreator 文档中的相关页面:Creating Custom Widgets for Qt Designer
标签: qt qt-designer qt5.6