Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Convert qt console to qt widget
Forum Updated to NodeBB v4.3 + New Features

Convert qt console to qt widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Annabela_Cortez
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • Kent-DorfmanK Online
      Kent-DorfmanK Online
      Kent-Dorfman
      wrote on last edited by
      #2

      no. they are entirely different things. you need to rewrite your console app as a gui app.

      A 1 Reply Last reply
      0
      • Kent-DorfmanK Kent-Dorfman

        no. they are entirely different things. you need to rewrite your console app as a gui app.

        A Offline
        A Offline
        Annabela_Cortez
        wrote on last edited by
        #3

        @Kent-Dorfman But can I move these console .cpp files and folders into gui app, and try like that?

        1 Reply Last reply
        0
        • Kent-DorfmanK Online
          Kent-DorfmanK Online
          Kent-Dorfman
          wrote on last edited by Kent-Dorfman
          #4

          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.

          1 Reply Last reply
          1
          • Pradeep P NP Offline
            Pradeep P NP Offline
            Pradeep P N
            wrote on last edited by
            #5

            Hi @Annabela_Cortez

            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 Nimbalkar.
            Upvote the answer(s) that helped you to solve the issue...
            Keep code clean.

            A 1 Reply Last reply
            5
            • Pradeep P NP Pradeep P N

              Hi @Annabela_Cortez

              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.

              A Offline
              A Offline
              Annabela_Cortez
              wrote on last edited by
              #6

              @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

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi,

                Take a look at the CMake Manual chapter in Qt's documentation. It shows you how to setup your project to use Qt.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved