Create .h and .cpp from a .ui file

Suppose I have an about.ui file. How can I make "about.h" and "about.cpp" from my .ui file? Do I need to create a .moc file? How can I compile this after creaton to make sure everything is spelled correctly?

+7
qt qt3 qt-creator qt-designer
source share
6 answers

If automatic generation does not work (as in my case), you can use uic to generate the header file manually. uic file.ui > file.h

+6
source share

QMake (actually uic) will automatically generate the ui_about.h file, which you can use to create about.cpp (just make sure the .pro file is correct). Here is the tutorial

You might also want to use the latest version of Qt (4.6).

+3
source share

You do not know. In about.ui, ui_about.h is created, which you include in your own about.h

Then you create your own class derived from this class

 class about : public QDialog, public Ui::about { Q_OBJECT; .... } 
+3
source share

Short answer:

In QtCreator, there are two ways to create a form from the Windows Assistant: - Qt Designer Form Class - QtDesigner Form

you must create a new β€œ Qt Designer Form Class ” instead of the β€œ Qt Designer Form ” because you select the β€œ Qt Designer Form ” . The qt creator does not create .h and .cpp files from the .ui file:

Long answer:

When you create a β€œQTCreator form”, create a .ui file, this is useful if you already have an existing class for the business logic of the user interface and you want to rebuild the user interface, but save the business logic, you can call buttom or components with the same name and exchange ui.

+3
source share

In VS2008, follow this step. Go to "Form Files-> Add-> Class-> Qt4Classes-> Q4GuiClass-> Add, then Fill in the class name and click Finish.

+1
source share

if you use qt creator in windows, just right click on your project and press run qmake, then it will generate ui_xxx.h and you can add #include ui_xxx.h to your file.

0
source share

All Articles