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. How to start other .exe and return value ?

How to start other .exe and return value ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 2.9k 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.
  • Taz742T Offline
    Taz742T Offline
    Taz742
    wrote on last edited by
    #1

    How to start other .exe and return value ?
    Is it possible?

    Do what you want.

    jsulmJ Taz742T 2 Replies Last reply
    0
    • Taz742T Taz742

      How to start other .exe and return value ?
      Is it possible?

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Taz742 http://doc.qt.io/qt-5/qprocess.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      Taz742T 1 Reply Last reply
      1
      • jsulmJ jsulm

        @Taz742 http://doc.qt.io/qt-5/qprocess.html

        Taz742T Offline
        Taz742T Offline
        Taz742
        wrote on last edited by
        #3

        @jsulm
        Yes I know how to run another program, but how do I get value from it?
        Maybe you give me the right direction

        Do what you want.

        jsulmJ 1 Reply Last reply
        0
        • Taz742T Taz742

          How to start other .exe and return value ?
          Is it possible?

          Taz742T Offline
          Taz742T Offline
          Taz742
          wrote on last edited by
          #4

          Let's assume that we are going to perform the operation that can be accomplished or not. I want to understand that.
          For small instance, I send a number to another exe and give it back if this number is less than 100.

          Do what you want.

          J.HilkJ 1 Reply Last reply
          0
          • Taz742T Taz742

            Let's assume that we are going to perform the operation that can be accomplished or not. I want to understand that.
            For small instance, I send a number to another exe and give it back if this number is less than 100.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @Taz742

            if you want to keep it simple:

            this Signal and this function most likly.

            alternatively, QSharedMemory, TCP/UDP ...


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            Taz742T 1 Reply Last reply
            1
            • J.HilkJ J.Hilk

              @Taz742

              if you want to keep it simple:

              this Signal and this function most likly.

              alternatively, QSharedMemory, TCP/UDP ...

              Taz742T Offline
              Taz742T Offline
              Taz742
              wrote on last edited by Taz742
              #6

              @J.Hilk
              If my process is run .exe program that has a form we can do emit true or false or QVector ... QList...?
              I can not understand how I could do that.

              Do what you want.

              jsulmJ 1 Reply Last reply
              0
              • Taz742T Taz742

                @jsulm
                Yes I know how to run another program, but how do I get value from it?
                Maybe you give me the right direction

                jsulmJ Online
                jsulmJ Online
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Taz742 Please read documentation, everything is there.
                See http://doc.qt.io/qt-5/qiodevice.html#readyRead, http://doc.qt.io/qt-5/qiodevice.html#write-2, http://doc.qt.io/qt-5/qprocess.html#readAllStandardOutput
                There is even an example showing how to do it:

                QProcess gzip;
                gzip.start("gzip", QStringList() << "-c");
                if (!gzip.waitForStarted())
                    return false;
                
                gzip.write("Qt rocks!");
                gzip.closeWriteChannel();
                
                if (!gzip.waitForFinished())
                    return false;
                
                QByteArray result = gzip.readAll();
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • Taz742T Taz742

                  @J.Hilk
                  If my process is run .exe program that has a form we can do emit true or false or QVector ... QList...?
                  I can not understand how I could do that.

                  jsulmJ Online
                  jsulmJ Online
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by jsulm
                  #8

                  @Taz742 said in How to start other .exe and return value ?:

                  If my process is run .exe program that has a form we can do emit true or false or QVector ... QList...?
                  I can not understand how I could do that.

                  You either use stdout/stdin like shown in my post above. Or you use some kind of IPC (Inter Process Communication). For example shared memory, DBus, ...
                  See http://doc.qt.io/qt-5/qtcore-ipc-sharedmemory-example.html for shared memory.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2
                  • VRoninV Offline
                    VRoninV Offline
                    VRonin
                    wrote on last edited by
                    #9

                    I think the main question here is: how does your external application returns the data?

                    • does it exit with a different code for each possible result (it would be unsual but I'm not ruling it out)?
                    • does it print to standard output (the console) the answer? if so in what format?
                    • does it communicate in any other way (shared memory,DBus,TCP,Local Socket, HTTP, FTP, etc)?

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of Qt

                    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