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. Run an .exe from other's application function
Forum Updated to NodeBB v4.3 + New Features

Run an .exe from other's application function

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 13.5k Views 1 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.
  • J Offline
    J Offline
    jk_mk
    wrote on last edited by
    #1

    Hi,

    I have created two different applications seperatly.A form named window and a form named my_mainwindow, and I want to run the window.exe when I call a press button function my_mainwindow application. I have written the following code, I debug my_mainwindow without any errors, but when I press the button I don't get my window form from the window.exe file.Also when I insert in my code the (system("pause");), when I press the button I get the cmd.exe .Could somebody help me?

    @QObject::connect(pushButton_openFile, SIGNAL(clicked()), this, SLOT(push_button_File()));@

    //////////////////////////////////

    @void my_mainwindow::push_button_File(void)
    {

    QProcess::execute("E:\Qt tutorial\Qt applications\window\window\window.exe");

    // system("pause");
    return ;
    }@

    1 Reply Last reply
    0
    • M Offline
      M Offline
      marko-a
      wrote on last edited by
      #2

      It likely has something to do with exe-file path. Try placing both EXE files in a same folder and use relative path... Also, why not make an instance of QProcess and use start() method as described "here":http://doc.qt.nokia.com/latest/qprocess.html#details?

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jk_mk
        wrote on last edited by
        #3

        I have moved both .exe files in the same directory and I have tried this, but with no any good result

        @void my_mainwindow::push_button_File(void)
        {

        QString program = "E:\Qt tutorial\Qt applications\my_mainwindow\my_mainwindow\window.exe";
        QProcess *myProcess = new QProcess(this);
        myProcess->start(program, 0);

        return ;
        }@

        1 Reply Last reply
        0
        • M Offline
          M Offline
          marko-a
          wrote on last edited by
          #4

          You should also change path to "window.exe". Also, as a second argument you are suppling 0. Why? If you have no arguments to send try: myProcess->start(program). Furthermore you should listen "some of these signals":http://doc.qt.nokia.com/latest/qprocess.html#signals to make sure window.exe is running, closing etc.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jk_mk
            wrote on last edited by
            #5

            To change path to "window.exe", this should be done from my project's properties, in my visual studio that I am using for the project?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              marko-a
              wrote on last edited by
              #6

              No no, I was referring to:
              @QString program = "E:\Qt tutorial\Qt applications\my_mainwindow\my_mainwindow\window.exe";@
              It should be:
              @QString program = "window.exe";@

              Also, you should try to run both apps from outside the IDE. Navigate to folder and run both EXEs. This is to make sure apps are not missing any DLLs.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jk_mk
                wrote on last edited by
                #7

                This was my mistake. I should have QString program = "window.exe"; in my code.
                Thanks a lot for your help.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  And change the path separators from backslashes ("") to regular forward slashes ("/"). Qt does the translation for you and if you really want to use the, you must double quote them, as the C/C++ compiler interprets them as string specials (like "\n"):

                  @
                  QString program = "E:/Qt tutorial/Qt applications/my_mainwindow/my_mainwindow/window.exe";
                  @

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jk_mk
                    wrote on last edited by
                    #9

                    thanks for your reply

                    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