Suppose I have the file about.ui. How can I make the "about.h" and the "about.cpp" from my .ui file? I have to create a .moc file too? How can I compile this after the creaton to see if all ocurred correctly?
6 Answers
If automatic generation does not work (like in my case) you can use uic to generate the header file manually. uic file.ui > file.h

- 1,807
- 1
- 24
- 30
-
Sounds like your .ui file is not listed in your .pro file or you didn't re-run qmake. – leemes Jul 27 '12 at 19:35
-
2Or maybe just QtCreator sucks, doesn't it? – Tomáš Zato Nov 27 '15 at 08:59
You don't.
The about.ui generates a ui_about.h which you include in your own about.h
You then create you own class deriving from this class
class about : public QDialog, public Ui::about
{
Q_OBJECT;
....
}

- 94,801
- 28
- 188
- 263
Short answer:
In QtCreator there are two ways of create a form from windows assistant: - Qt Designer Form Class - QtDesigner Form
you must create a new "Qt Designer Form Class" instead of "Qt Designer Form", because you choose "Qt Designer Form" qt creator doesn't create the .h and .cpp from .ui file:
Long Answer:
When you create "QTCreator Form" only create .ui file this is useful if you already have an existing class for the UI business logic and you want rebuilt user interface but keep business logic, you can call buttom or components with same name and interchange ui.

- 633
- 7
- 9
-
1If I use QtCreator to create a class, then will it create myClass.ui, ui_myClass.h, MyClass.h, and MyClass.cpp files? I'm asking because I have a otherClass.ui file that I'd like to create a class with otherClass.h and otherClass.cpp. Previously, I did such a thing, and I think I used QtCreator. However, I can't recall now how I generated the MyClass.h and MyClass.cpp files from the .ui file. – user3731622 Feb 10 '16 at 23:25
QMake (actually uic) will automatically generate a ui_about.h
file that you can use to make about.cpp (just make sure to get the .pro file right). Here's a tutorial
You might want to use the lastest Qt (4.6) too btw.

- 527
- 2
- 4
-
2Link is dead. This is why you're supposed to quote tutorials here, while giving them credits. – Tomáš Zato Nov 27 '15 at 09:00
IN VS2008 Follow this step Go to Form Files->Add->Class->Qt4Classes->Q4GuiClass->Add , then Fill the class name and click on Finish.

- 11
- 1