Convert qt console to qt widget
-
Hi,
Is there an option to convert old qt5 console program into qt widget app? I have to insert ui from qt widget into console app? -
no. they are entirely different things. you need to rewrite your console app as a gui app.
-
@Kent-Dorfman But can I move these console .cpp files and folders into gui app, and try like that?
-
The most you can hope for is to reuse some of the process logic. To do a gui app properly involes analysis and a shift in programming paradigm to event based.
-
Yes with some changes in the code its doable.
You can include the GUI (Widget) code in the Qt console application.
In this case you also have to change the .pro file completely to support the Qt GUI & widgets.
Look at the below code.console APP .pro file which does not support the Qt you have to change things here.
TEMPLATE = app CONFIG += console c++11 // console is the reason ro run it as console app remove it to get rid off console CONFIG -= app_bundle CONFIG -= qt SOURCES += main.cpp
change to support Qt
CONFIG += c++11 // remove console CONFIG += app_bundle QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets // remaining stuff
Change your main.cpp to support the QApplication
You are ready to migrate console APP to Widget APP.
Have a great day. -
@Pradeep-P-N I dont' have .pro file because this project is compiled using CMake, and I have to add UI to it, and start it. But I don't know how to modify it
-
Hi,
Take a look at the CMake Manual chapter in Qt's documentation. It shows you how to setup your project to use Qt.