How to create header file and source file .ui file in Qtdesigner?

I have an application in which I have a mainwindow.ui file, and I create a new dialoge.ui constructor file in the same application, how can I create a source file and a header file for dialoge.ui. I am using QtCreater (windows).

I'm new to qt, I think there should be a way for this, but I don't get it. Help me. Thanks

+6
source share
5 answers

I'm not sure I fully understood your question. You have an application developed in QtCreator in which you have 2 .ui files. And you want to generate the appropriate header / source files for these 2 files.

Using QtCreator, you don’t have to worry about creating header files. This is done automatically. During the build phase, the User Interface Compiler (uic) is called and translates the .xml files into C ++ header files.

+2
source

You can create the source and the header from the .ui file from the outside, and then import them into your application (do not forget to link later in the .pro file). Create an executable file (.bat or .exe) to run the following commands. Below is a shell script (I'm a linux user.)

 echo HEADERS <path to your uic compiler>/uic -o form.h form.ui echo SOURCES <path to your uic compiler>/uic -i form.h -o form.cpp form.ui 
+8
source

For each someidget.ui file, ui_somewidget.h and ui_somewidget.cpp will be created during the build process. The tool used to create them is uic. All you have to do is make sure that .ui files are added to your project's .pro file along with other source and header files, for example:

  FORMS += somewidget.ui 

qmake / make will automatically generate and create .cpp and .h files for someidget.ui.

+3
source

You can do it:

Save the dialoge.ui file in the directory. Use qmake to create a .pro file (qmake -project), qmake is smart enough to detect .ui. It will also generate appropriate makefile rules to invoke uic, the Qt user interface compiler. If you are using visual studio, you can call qmake -tp vc, this will create a visual studio project, connected and ready to use. The visual studio project will generate ui_dialoge.h for you, you can copy it to another project and use it in another header file that this .ui dialog will use

+1
source

In addition to the already correct answers: transition from debug mode to release mode in the general settings. In my case, the header file was not created in debug mode

0
source

Source: https://habr.com/ru/post/886304/


All Articles