[Qt-interest] uic, QMainWindow and non QWidget central widgets
Karol Krizka
kkrizka at gmail.com
Wed Dec 31 01:22:58 CET 2008
Hi all,
I am using Designer to design a QMainWindow that contains a non-QWidget
central widget. I accomplished this by designing my layout and manually
editing the generated .ui file and manually promoting the central widget.
However, when I run the uic command, the central widget is not added using
setCentralWidget.
For example, I have the following .ui file. Instead of promoting QWidget to a
custom widget, I simplified it and replaced the central widget with a simple
QFrame:
<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>MainWindow</string>
</property>
<widget class="QFrame" name="centralwidget" />
<widget class="QMenuBar" name="menubar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar" />
</widget>
<resources/>
<connections/>
</ui>
Now, run the following command (along with the output):
kkrizka at tiny101 ~/test $ uic untitled.ui | grep -i setCentral
kkrizka at tiny101 ~/test $
If I change QFrame back to QWidget, I get the following:
kkrizka at tiny101 ~/test $ uic untitled.ui | grep -i setCentral
MainWindow->setCentralWidget(centralwidget);
kkrizka at tiny101 ~/test $
Is this a problem with the uic command or some known limitation?
Btw, it works quite well if I dynamically load the .ui file with QUiLoader.
Cheers,
Karol Krizka
More information about the Qt-interest-old
mailing list