5

How do you compile the UI files to generate the Headers? Is there another way then having the Qt project mirror the visual studio project and compiling with Qt to get them? I guess I could have a bat file or something that does it. What needs to be run to generate the header files from the UI?

3 Answers 3

8

You have to use uic on the .ui file. This will give you the .h and the .cpp. Normally you reimplement the classes generated by this step, basically considering them abstract.

Sign up to request clarification or add additional context in comments.

4 Comments

moc is a different tool. It takes the pseudo C++ you use to define signals and slots, and convert it into real C++. uic takes a .ui file (which is a xml file) and creates you the C++ code.
When I tried building the other day it created 3 files Form.h, Form.cpp and ui_form.h. I tried using those and the only problem were unresolved functions which when I googled them people were saying the error is caused by not mocing the class.
could be, Now I don't remember if the uic product contains already moced stuff or not, but I think it doesn't. So you have to moc the header file you obtain. In any case, if you use qmake, it does everything for you.
But I want to use visual studio to build my project.
6

In most situations you shouldn't be dealing with uic or moc directly.
You have qmake to take care of business for you.

qmake generates a Makefile based on the information in a project file. Project files are created by the developer, and are usually simple, but more sophisticated project files can be created for complex projects. qmake contains additional features to support development with Qt, automatically including build rules for moc and uic. qmake can also generate projects for Microsoft Visual studio without requiring the developer to change the project file.

4 Comments

How do you use qmake with visual studio?
Okay that isn't really what I want. I want my main IDE to be visual studio.
did you read about qmake at all? the last sentence of the quote I gave says you can generate vcproj files using qmake. anyhow what you really want is probably the Qt add-in for Visual Studio: qt.nokia.com/downloads/visual-studio-add-in
I tried the visual studio addin but there are only 3 enabled options. Launch the designer, launch the linguist, and import the .pro to overwrite my visual studio project which I don't want to do.
1

Try to create new Visual Studio project, and then choose "Qt Application" or similar - don't choose MFC application, etc... For this you have to have Qt add-in for Visual Studio. This will set it up all automatically, so you will build everything from VS.

Cheers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.