Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Start an external program from Qt

    General and Desktop
    4
    9
    1831
    Loading More Posts
    • 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.
    • T
      Timo_F last edited by

      Hello everybody,

      ich developped a vision app and now I want to start that app by pushing a button on an Qt gui.
      More precise the button is on the MainWindow.
      I found a lot of hints in the web but they are not working for me.

      QProcess * my process = new QProcess();
      myprocess-> start("absoulte path", QStreingList() << "Start");
      I also used startDetached , but that's also not working.
      Does anyboy have an example for me?

      Thanks a lot.

      Kindy regards,

      Timo

      1 Reply Last reply Reply Quote 0
      • L
        luca last edited by

        Have you tried with the static call:

        QProcess::startDetached(......);
        
        1 Reply Last reply Reply Quote 0
        • T
          Timo_F last edited by

          Yes, but nothing happens ...

          tham 1 Reply Last reply Reply Quote 0
          • tham
            tham @Timo_F last edited by

            @Timo_F Which platform and Qt version? Any error messages?One of the reasons I could imagine is privilege, if you are doing the task on windows, you need to change the privilege by manifest.

            Example of manifest :

            <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
            <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
                <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
                    <security>
                        <requestedPrivileges>
                            <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
                        </requestedPrivileges>
                    </security>
                </trustInfo>
            </assembly>
            

            And call the mt.exe, you can save some trouble by adding following lines in .pro

            win32 {
                WINSDK_DIR = C:/Program Files (x86)/Windows Kits/10
                WIN_PWD = $$replace(PWD, /, \\)
                OUT_PWD_WIN = $$replace(OUT_PWD, /, \\)
                message("output : " + $$OUT_PWD_WIN)
                QMAKE_POST_LINK = "$$WINSDK_DIR/bin/x86/mt.exe -manifest $$quote($$WIN_PWD\\$$basename(TARGET).manifest) -outputresource:$$quote($$OUT_PWD_WIN\\${DESTDIR_TARGET};1)"
            }
            

            Maybe the app compiled by mingw do not need to go through this kind of troubles

            1 Reply Last reply Reply Quote 0
            • T
              Timo_F last edited by

              @tham
              there are no errors ... it's like death. I'm using Qt 5.8 on Windows10.
              Where is the manifest doc?

              tham mrjj 2 Replies Last reply Reply Quote 0
              • tham
                tham @Timo_F last edited by

                @Timo_F Embedding Application Manifest and Version Information using QtCreator.

                1 Reply Last reply Reply Quote 0
                • mrjj
                  mrjj Lifetime Qt Champion @Timo_F last edited by

                  @Timo_F said in Start an external program from Qt:

                  @tham
                  there are no errors ... it's like death. I'm using Qt 5.8 on Windows10.

                  So you did hook up
                  http://doc.qt.io/qt-5/qprocess.html#errorOccurred
                  and see what it says ?

                  1 Reply Last reply Reply Quote 0
                  • T
                    Timo_F last edited by

                    Thank you all a lot. :-)
                    Now it works ... shame on me, it was so simple. I copied and paste the path directly from the explorer and that was not working. Replacing the "" by "/" in the path was the solution !!

                    mrjj 1 Reply Last reply Reply Quote 0
                    • mrjj
                      mrjj Lifetime Qt Champion @Timo_F last edited by

                      @Timo_F
                      Oh its a classic
                      to use

                      \
                      in any c/c++ it must be escaped
                      \\
                      or use / as Qt supports.
                      
                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post