I would like to have a QTabWidget with a tab containing a custom widget.
I created a custom Widget (consisting of a .ui, .h and .cpp file)
I added this custom Widget to the first page of my
QTabWidget, but the content of this Widget is not shown in QtCreator's designer.I promoted my custom Widget as
Tab1Custom.
This setup compiles and works as expected when I run the program, but my custom control doesn't show up in QtCreator's designer.
What can I do to make my custom control show up in QtCreator's designer?
Here's the first part of 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>
....
This is how it works when you use a custom widget and promote it. In order to have your widget drawn with content, you have to create a DLL to extend Qt Designer. Look at "Creating Custom Widgets for Qt Designer" for more information on that.
For the most part, I don't think it's worth the effort to do this; generally speaking, it's fine that it just shows a either a blank widget or whatever base widget you promoted.