Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to create .CPP class for a Form?
I have created a Form "Test" (TEST.UI file) using Qt Creator Form Designer.
How do I automatically generate the corresponding TEST.CPP file that contains the object definition, creator/destructor, etc?
Hi and welcome to devnet,
UIC += test.uito your .pro file.
FORMS += test.uito your .pro file.
Did you only create the .ui file or did you ask for a widget to be used with designer ? If the later, you should already have everything needed in your .pro file.
[edit: fixed qmake variable name SGaist]
@SGaist shouldn't that be
FORMS += test.ui?
@aha_1980 Yes, you're correct ! Looking at cmake stuff and got it mixed :)
I wonder if u choose the wrong template to begin with ?
That one create both .h and .cpp and UI file.
The one next in list, creates ONLY the UI file.
@SGaist My .PRO file does contain
FORMS += test.ui
@mrjj Yes I do believe I chose "Qt Designer Form" (instead of "Qt Designer Form Class")
I will try the "Class" version.
Yes, that was the problem. The solution is to choose "Qt Designer Form Class".
I will be writing a utility to convert 300 Win32 Resource dialogs to Qt. I looked at KNUT: by the time I figure out how to compile and run it, I can write the conversion program. Plus, KNUT uses the .EXE, I have an .RC file.
Holy mother of old code.
30300 dialogs in one program?
What is knut ? Do you have a link to it ?
Note that Qts UI files are XML and could be produced from
Sprezzatura last edited by Sprezzatura
That's three hundred dialogs, not thirty (includes multi-page Property Sheets) :o)
KNUT used to be offered by KDAB, the Qt consulting company. It is no longer mentioned on their site.
You can get the source code for KNUT from here:
I can see how Qt .UI files are structured. It will be fairly straightforward to convert a Visual Studio .RC to XML. I can even automatically generate the class .CPP and .H files.
Yes, typo :) Thats massive.
Ah, that is old :) Qt3 code will need changes to compile
on 5.11. But interesting never the less.
Just as a note in case you missed it
Qt dont actually use the UI at runtime. its already converted to c++ code.
@mrjj and @SGaist Thanks very much for your help. My "RCtoUI" conversion program is starting to produce results. It's great to open up a .UI file with Qt Creator and magically see the dialog appear. It looks like I have to multiply the VS RC dialog units by 2 to get them to scale and look OK in Qt.
I will provide a link to download the RCtoUI executable (when it's completed) if anyone is interested.
Im pretty sure anyone faced with the task of converting old win32
dialog code to Qt would find RCtoUI very useful so please do
And congrats with the progress :)