Qt (3) Check QtDesigner and the ui file
Published on| May 22nd, 2009 | No Comment.
Categories:Qt |
Description: Qt is most likely features of Qt, moc and uic compiler that is to have one. (Described in the same post)
This article does not explain the previously described features of uic.
Qt, if you create a user interface, Windows do not use a resource file to use. Resource file handling in Qt is defined as an image file. Qt can write directly in the source code of the screen image, we do not need a special resource file.
However, VisualBasic and RAD Tool For those accustomed to the screen while creating a source of imagination, it is also painful. So, Qt uses, Qt Designer is included with that.
The Qt Designer, you can paste the screen to create images of the actual screen. However, Windows does not output the file as resource. This file output, XML output format ui text file called.
Qt uses this file ui C / C + + to convert a header in the build (compile + link). Ui this file C / C + + header conversion to uic (User Interface Compiler) we do.
This. I'd like to use to explain the flow of the sample source.
Program used here is a sample program that helps判RI are listed below the site, some are changed.
MOC: Meta Object Compiler
UIC: User Interface Compiler
UIC: User Interface Compiler
Related Sites: http://doc.trolltech.com/4.5/designer-using-a-ui-file.html
Sample source code you used here:
QtDesigner create an image on screen
This does not make a screen from the source code.
QtDesigner create a screen, ui file.
QtDesigner is usually the following names respectively.
%Qtinstallationdirectory%\qt\bin\designer.exe
Double-click it to start.
Perhaps you start, I would stand up to the first screen below. So, "Widget" and select, then click Create.
This will only create a simple form that only one button.

※ If your maichin(PC) do not start up above the screen, please click [File] - [New]. Your pc will show to the same screen.
I have seen nothing in the middle of the screen.

Around the middle of the screen on the left "PushButton" drag the mouse and let's drop.
I think I created a button on the screen below.

This, click the Save to the appropriate directory "test.ui" Let's save it.
The output is then the following text. This, XML file format itself ui.
[test.ui]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>Form</class> <widget class="QWidget" name="Form"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>400</width> <height>300</height> </rect> </property> <property name="windowTitle"> <string>Form</string> </property> <widget class="QPushButton" name="pushButton"> <property name="geometry"> <rect> <x>110</x> <y>130</y> <width>75</width> <height>23</height> </rect> </property> <property name="text"> <string>PushButton</string> </property> </widget> </widget> <resources/> <connections/> </ui> |
16 lines per second "QPushButton" There is, perhaps, in the air, this might be added in the information button.
For this format, were written in detail, I'm not.
I'll ride the page has been officially published, but is this just have been written.
Qt Designer's UI File Format: http://doc.trolltech.com/4.5/designer-ui-file-format.html
Look to this page, you write and format may change, harder, and I do not even need to understand the contents.
Roughly, about what is good in what.
I'll ride the page has been officially published, but is this just have been written.
Qt Designer's UI File Format: http://doc.trolltech.com/4.5/designer-ui-file-format.html
Look to this page, you write and format may change, harder, and I do not even need to understand the contents.
Roughly, about what is good in what.
This file is ui, XML format, so, C / CPP does, it does not recognize.
Even with this XML file can be used in loading the application.
We will see later.
This work based on the basic operating procedures.
We will see later.
This work based on the basic operating procedures.
ui can be converted into a header file uic (User Interface Compiler).
So, immediately, let's use it. Then input the following command.
1 | C:\temp> uic -o ui_test.h test.ui |
When this command is finished, "ui_test.h" is output.
Let's look at this file.
[ui_test.h]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | /******************************************************************************** ** Form generated from reading ui file 'test.ui' ** ** Created: Fri May 22 10:32:02 2009 ** by: Qt User Interface Compiler version 4.5.1 ** ** WARNING! All changes made in this file will be lost when recompiling ui file! ********************************************************************************/ #ifndef UI_TEST_H #define UI_TEST_H #include <QtCore/QVariant> #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QButtonGroup> #include <QtGui/QHeaderView> #include <QtGui/QPushButton> #include <QtGui/QWidget> QT_BEGIN_NAMESPACE class Ui_Form { public: QPushButton *pushButton; void setupUi(QWidget *Form) { if (Form-->objectName().isEmpty()) Form-->setObjectName(QString::fromUtf8("Form")); Form-->resize(400, 300); pushButton = new QPushButton(Form); pushButton-->setObjectName(QString::fromUtf8("pushButton")); pushButton-->setGeometry(QRect(110, 130, 75, 23)); retranslateUi(Form); QMetaObject::connectSlotsByName(Form); } // setupUi void retranslateUi(QWidget *Form) { Form-->setWindowTitle(QApplication::translate("Form", "Form", 0, QApplication::UnicodeUTF8)); pushButton-->setText(QApplication::translate("Form", "PushButton", 0, QApplication::UnicodeUTF8)); Q_UNUSED(Form); } // retranslateUi }; namespace Ui { class Form: public Ui_Form {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_TEST_H |
To note is the following.
- Ui_Form that class does not inherit anything
- Form class that is, Ui_Form are inherited only
QMainWindow and QWidget, Other, QPushButton and does not inherit anything.
I think this is just like Qt. If you file a class from the MFC, and other resources, but most, CWnd is a common pattern of inheritance that is ready for more children. However, I do not like Qt or meaner than the feeling that we will take a twist.
I maybe think want to use inheritance function. But wise engineer find another way out there and speak.
The story wandered. So, Created by the header of Ui_Form, Form I can use in any class.
It is one of the following answers.
[sample.cpp]
1 2 3 4 5 6 7 8 9 10 11 12 | #include "ui_test.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget *widget = new QWidget; Ui::Form ui; ui.setupUi(widget); widget-->show(); return app.exec(); } |
It is very simple.
What the basic screen (here, QWidget has generated a 6 per line), and were automatically created Ui:: Form passing, I embed the basic screen.
Embedded, if you view the screen in "setupUi" I was in the add, I can see it.
I was one of the following screen.

You can create a different screen to add a few hands.
To describe yourself, where sample.cpp the 12 degree line is, considering only the screen, RAD Maybe so if I said tool.
Because this QtDesigner, Qt's developer, Qt is saying it looks like RAD tool. However, I do not know. Personally, RAD tools and speaking, I image of VB6 . Do you think?
Because this QtDesigner, Qt's developer, Qt is saying it looks like RAD tool. However, I do not know. Personally, RAD tools and speaking, I image of VB6 . Do you think?
Now, the screen can this be, in fact, had a signal when the button is clicked, I want to define a slot.
You might also like:
Trackback URL
After Admin approves this comment, it will be shown.
Comments
Leave a Reply
