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. Need to create a Graphical Interface for a C++ CLI Application
QtWS25 Last Chance

Need to create a Graphical Interface for a C++ CLI Application

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 2.5k Views
  • 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.
  • N Offline
    N Offline
    nnicou
    wrote on last edited by
    #1

    Hello i am trying to create a Gui for a CLI application and i have the limitation that i cant change the source code or add to QT so i chose to do it by using Sockets.
    Questions:

    1. I want to create a c++ class with the sockets and the logic of the simulator there and i update the QML from there. Which approach is better?
      a. Create a new thread and run it simultaneously with the qui?
      b. I found how to change the properties from main.cpp but i cant make it work from different cpp class
      code i used:(i understand the code from main.cpp but i didnt find anything helpful when i want to do it from different class)
      @QObject *rootObject = engine.rootObjects().first();
      QObject qmlObject = rootObject->findChild<QObject>("rect");
      rootObject->setProperty("visible", true);
      qmlObject->setProperty("color", "yellow");@
      c. Is it better to instantiate the whole GUI from c++?

    I am kinda confused i try alot of stuff but i am not sure which is correct. Till now i try the socket part and did some of the gui so i need to figure out how to process the data from application send by sockets and then change attributes of gui(for starter i want to try changing shape's colors )

    Thanks in advance!

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

      Hi,

      What kind of information are you exchanging with that CLI application ?

      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
      0
      • N Offline
        N Offline
        nnicou
        wrote on last edited by
        #3

        Hello,
        I will need to exchange strings and integers from the cli Application and i will need to process those information before i change the attributes in Gui. Basically the CLI application is a NOC simulator and i need to show how the packets are traversing the network.
        Thanks in advance

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

          Then as your wrote you should first create a class that will handle the communication with your simulator.

          Then you can pass an instance of that class to your QML GUI and handle things there.

          That would be the most straightforward.

          Does that simulator run on his own or do you need to start it from your GUI application ?
          Does it offer other channels of communication ?

          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
          0
          • N Offline
            N Offline
            nnicou
            wrote on last edited by
            #5

            Thats helpful, and is it better to instantiate QML from c++ or just send information to qml and use some logic there to change qml?
            Simulator run on his own and yes i prefer to start it from Gui by creating new process and run a terminal. No it doesnt offer other channels of communication..
            Thank you in advance

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

              Write your GUI as usual, then in your main function, create your "controller" object and pass it to QML where you'll be doing whatever connection is needed.

              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
              • N Offline
                N Offline
                nnicou
                wrote on last edited by
                #7

                I think i got the main idea and thank you very much for the support. I will start from the CLI APPlication and use command line to print the data and the continue with the GUI.

                Something to close the topic,the controller that i will create it will consists with alot of connections is a class ? an object and do you have anything for reference? or an example?

                Something like this?
                https://www.wisol.ch/w/articles/2014-12-15-qt-signal-slots-qml-cpp/

                Thank you in advance

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

                  Yes but please use better naming ;)

                  You can also take a look at the Integrating QML and C++ chapter of Qt's documentation.

                  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
                  0
                  • N Offline
                    N Offline
                    nnicou
                    wrote on last edited by
                    #9

                    Thank you alot that would be helpful and thanks for your time ! This forum is so help!

                    1 Reply Last reply
                    0

                    • Login

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