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,
AddUIC += test.ui
to your .pro file.Add
FORMS += test.ui
to 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]
-
Hi and welcome to devnet,
AddUIC += test.ui
to your .pro file.Add
FORMS += test.ui
to 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]
-
Hi
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.
-
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.
-
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.
@Sprezzatura
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
external application. -
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:
https://www.opendesktop.org/c/1466642231
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.
-
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:
https://www.opendesktop.org/c/1466642231
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.
@Sprezzatura
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
http://doc.qt.io/qt-5/uic.html
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.
-
@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.
@Sprezzatura
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 :)