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. QProcess starting separate Qt application based on QWidget class
Qt 6.11 is out! See what's new in the release blog

QProcess starting separate Qt application based on QWidget class

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 5 Posters 5.4k 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
    Jendker
    wrote on last edited by Jendker
    #1

    Hello everyone, this is my first post on the forum!

    I am the beginner in Qt and I am struggling with starting the application in Windows, which I have written with Qt, the application which I am trying to start (child) is based on QtWidget class (32-bit) and I am starting it with program (parent) based on QtMainWindow class (64-bit).

    The program is starting correctly with start(), I can see it in the Task Manager, state() command returns 2 (QProcess::Running) but it does not start any window. Then I tried the startDetached(), but it also failed.
    I know, that the program does produce the output, it does so, when I start this child process separately so in order to check if the program is actually running I was checking to children stdout with

    connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(processOutput()));  // connect process signals with your code
    connect(process, SIGNAL(readyReadStandardError()), this, SLOT(processOutput()));  // same here
    

    and

    void BroadcasterGUI::processOutput()
    {
    	qDebug() << process->readAllStandardOutput();  // read normal output
    	qDebug() << process->readAllStandardError();  // read error channel
    }
    

    but no output was produced. Tried also with

    process->setStandardOutputFile("D:\\<Program path>\\output.txt");
    process->start(exeFile);
    

    the output file is created, but no input appears in it.
    And still trying something as simple as

    QProcess *process = new QProcess(parent);
    QString program = "\"C:\\Program Files (x86)\\Notepad++\\notepad++.exe\"";
    process->start(program);
    

    starts the notepad++ without any problems.

    I will be very helpful for any indications what should I do different to solve this issue, because it seems for now, that I will need to start the application in Qt in a different, separate way without incorporating QProcess... It is always possible, but I would be happy to be able to use the features the QProcess provides.

    Taz742T J 3 Replies Last reply
    0
    • J Jendker

      Hello everyone, this is my first post on the forum!

      I am the beginner in Qt and I am struggling with starting the application in Windows, which I have written with Qt, the application which I am trying to start (child) is based on QtWidget class (32-bit) and I am starting it with program (parent) based on QtMainWindow class (64-bit).

      The program is starting correctly with start(), I can see it in the Task Manager, state() command returns 2 (QProcess::Running) but it does not start any window. Then I tried the startDetached(), but it also failed.
      I know, that the program does produce the output, it does so, when I start this child process separately so in order to check if the program is actually running I was checking to children stdout with

      connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(processOutput()));  // connect process signals with your code
      connect(process, SIGNAL(readyReadStandardError()), this, SLOT(processOutput()));  // same here
      

      and

      void BroadcasterGUI::processOutput()
      {
      	qDebug() << process->readAllStandardOutput();  // read normal output
      	qDebug() << process->readAllStandardError();  // read error channel
      }
      

      but no output was produced. Tried also with

      process->setStandardOutputFile("D:\\<Program path>\\output.txt");
      process->start(exeFile);
      

      the output file is created, but no input appears in it.
      And still trying something as simple as

      QProcess *process = new QProcess(parent);
      QString program = "\"C:\\Program Files (x86)\\Notepad++\\notepad++.exe\"";
      process->start(program);
      

      starts the notepad++ without any problems.

      I will be very helpful for any indications what should I do different to solve this issue, because it seems for now, that I will need to start the application in Qt in a different, separate way without incorporating QProcess... It is always possible, but I would be happy to be able to use the features the QProcess provides.

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

      @Jendker
      please try startDetached
      process->startDetached()

      Do what you want.

      1 Reply Last reply
      0
      • J Jendker

        Hello everyone, this is my first post on the forum!

        I am the beginner in Qt and I am struggling with starting the application in Windows, which I have written with Qt, the application which I am trying to start (child) is based on QtWidget class (32-bit) and I am starting it with program (parent) based on QtMainWindow class (64-bit).

        The program is starting correctly with start(), I can see it in the Task Manager, state() command returns 2 (QProcess::Running) but it does not start any window. Then I tried the startDetached(), but it also failed.
        I know, that the program does produce the output, it does so, when I start this child process separately so in order to check if the program is actually running I was checking to children stdout with

        connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(processOutput()));  // connect process signals with your code
        connect(process, SIGNAL(readyReadStandardError()), this, SLOT(processOutput()));  // same here
        

        and

        void BroadcasterGUI::processOutput()
        {
        	qDebug() << process->readAllStandardOutput();  // read normal output
        	qDebug() << process->readAllStandardError();  // read error channel
        }
        

        but no output was produced. Tried also with

        process->setStandardOutputFile("D:\\<Program path>\\output.txt");
        process->start(exeFile);
        

        the output file is created, but no input appears in it.
        And still trying something as simple as

        QProcess *process = new QProcess(parent);
        QString program = "\"C:\\Program Files (x86)\\Notepad++\\notepad++.exe\"";
        process->start(program);
        

        starts the notepad++ without any problems.

        I will be very helpful for any indications what should I do different to solve this issue, because it seems for now, that I will need to start the application in Qt in a different, separate way without incorporating QProcess... It is always possible, but I would be happy to be able to use the features the QProcess provides.

        J Offline
        J Offline
        Jendker
        wrote on last edited by Jendker
        #3

        @Jendker said in QProcess starting separate Qt application based on QWidget class:

        The program is starting correctly with start(), I can see it in the Task Manager, state() command returns 2 (QProcess::Running) but it does not start any window. Then I tried the startDetached(), but it also failed.

        Checked, it also does not solve the issue.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tomma
          wrote on last edited by
          #4

          Have you deployed both applications with their own Qt libraries?
          Most likely the problem is that your 32bit application can't find correct Qt libraries.

          J 1 Reply Last reply
          0
          • T tomma

            Have you deployed both applications with their own Qt libraries?
            Most likely the problem is that your 32bit application can't find correct Qt libraries.

            J Offline
            J Offline
            Jendker
            wrote on last edited by Jendker
            #5

            @tomma
            In order to start 32bit application I am changing the working directory so that the application does find the Qt library, if I do not set this path I get an error on startup, so I guess this thing is solved properly. If I should check it in a specific way please let me know!

            1 Reply Last reply
            0
            • J Jendker

              Hello everyone, this is my first post on the forum!

              I am the beginner in Qt and I am struggling with starting the application in Windows, which I have written with Qt, the application which I am trying to start (child) is based on QtWidget class (32-bit) and I am starting it with program (parent) based on QtMainWindow class (64-bit).

              The program is starting correctly with start(), I can see it in the Task Manager, state() command returns 2 (QProcess::Running) but it does not start any window. Then I tried the startDetached(), but it also failed.
              I know, that the program does produce the output, it does so, when I start this child process separately so in order to check if the program is actually running I was checking to children stdout with

              connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(processOutput()));  // connect process signals with your code
              connect(process, SIGNAL(readyReadStandardError()), this, SLOT(processOutput()));  // same here
              

              and

              void BroadcasterGUI::processOutput()
              {
              	qDebug() << process->readAllStandardOutput();  // read normal output
              	qDebug() << process->readAllStandardError();  // read error channel
              }
              

              but no output was produced. Tried also with

              process->setStandardOutputFile("D:\\<Program path>\\output.txt");
              process->start(exeFile);
              

              the output file is created, but no input appears in it.
              And still trying something as simple as

              QProcess *process = new QProcess(parent);
              QString program = "\"C:\\Program Files (x86)\\Notepad++\\notepad++.exe\"";
              process->start(program);
              

              starts the notepad++ without any problems.

              I will be very helpful for any indications what should I do different to solve this issue, because it seems for now, that I will need to start the application in Qt in a different, separate way without incorporating QProcess... It is always possible, but I would be happy to be able to use the features the QProcess provides.

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

              @Jendker said in QProcess starting separate Qt application based on QWidget class:

              process->setStandardOutputFile("D:\<Program path>\output.txt");
              process->start(exeFile);

              Try QFile file("D:\<Program path>\output.txt");
              if(file.exists){
              Verify the file if you have this address is correct.
              }

              Do what you want.

              J 1 Reply Last reply
              0
              • Taz742T Taz742

                @Jendker said in QProcess starting separate Qt application based on QWidget class:

                process->setStandardOutputFile("D:\<Program path>\output.txt");
                process->start(exeFile);

                Try QFile file("D:\<Program path>\output.txt");
                if(file.exists){
                Verify the file if you have this address is correct.
                }

                J Offline
                J Offline
                Jendker
                wrote on last edited by Jendker
                #7

                @Taz742
                If I understand your post properly: yes, the path is correct, the file is created in the given directory, but it reamains empty after running the program.

                mrjjM 1 Reply Last reply
                0
                • J Jendker

                  @Taz742
                  If I understand your post properly: yes, the path is correct, the file is created in the given directory, but it reamains empty after running the program.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Jendker
                  Hi
                  If you go to the location of the application and click it.
                  Does it then start normally ?

                  J 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @Jendker
                    Hi
                    If you go to the location of the application and click it.
                    Does it then start normally ?

                    J Offline
                    J Offline
                    Jendker
                    wrote on last edited by Jendker
                    #9

                    @mrjj
                    Hi
                    Yes, it does start without any problems.

                    Do give you some details which may be relevant:

                    • the child process has subsystem: Windows defined and is written with VS Tools Plugin
                    • I am starting the parent with the console in the following way (as I am working in VS):
                    #ifdef DEBUG
                    	// detach from the current console window
                    	// if launched from a console window, that will still run waiting for the new console (below) to close
                    	// it is useful to detach from Qt Creator's <Application output> panel
                    	FreeConsole();
                    
                    	// create a separate new console window
                    	AllocConsole();
                    
                    	// attach the new console to this application's process
                    	AttachConsole(GetCurrentProcessId());
                    
                    	// reopen the std I/O streams to redirect I/O to the new console
                    	freopen("CON", "w", stdout);
                    	freopen("CON", "w", stderr);
                    	freopen("CON", "r", stdin);
                    #endif
                    

                    And was trying to start the child with such console activated and not, it did not make any difference, the window did not appear.

                    mrjjM 1 Reply Last reply
                    0
                    • J Jendker

                      @mrjj
                      Hi
                      Yes, it does start without any problems.

                      Do give you some details which may be relevant:

                      • the child process has subsystem: Windows defined and is written with VS Tools Plugin
                      • I am starting the parent with the console in the following way (as I am working in VS):
                      #ifdef DEBUG
                      	// detach from the current console window
                      	// if launched from a console window, that will still run waiting for the new console (below) to close
                      	// it is useful to detach from Qt Creator's <Application output> panel
                      	FreeConsole();
                      
                      	// create a separate new console window
                      	AllocConsole();
                      
                      	// attach the new console to this application's process
                      	AttachConsole(GetCurrentProcessId());
                      
                      	// reopen the std I/O streams to redirect I/O to the new console
                      	freopen("CON", "w", stdout);
                      	freopen("CON", "w", stderr);
                      	freopen("CON", "r", stdin);
                      #endif
                      

                      And was trying to start the child with such console activated and not, it did not make any difference, the window did not appear.

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Jendker said in QProcess starting separate Qt application based on QWidget class:

                      , the window did not appear.

                      Window being a console (cmd) window ?

                      J 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        @Jendker said in QProcess starting separate Qt application based on QWidget class:

                        , the window did not appear.

                        Window being a console (cmd) window ?

                        J Offline
                        J Offline
                        Jendker
                        wrote on last edited by Jendker
                        #11

                        @mrjj
                        No, the child is the QtWidget class based application, I was trying to start it with start() and startDetached() and the appplication only appeared in Task Manager in both cases. When I start it manually it works without any problems.

                        mrjjM 1 Reply Last reply
                        0
                        • J Jendker

                          @mrjj
                          No, the child is the QtWidget class based application, I was trying to start it with start() and startDetached() and the appplication only appeared in Task Manager in both cases. When I start it manually it works without any problems.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @Jendker
                          it must be something simple then.
                          The program you trying to start do have a complete deployment folder with all needed Dlls?

                          J 1 Reply Last reply
                          0
                          • mrjjM mrjj

                            @Jendker
                            it must be something simple then.
                            The program you trying to start do have a complete deployment folder with all needed Dlls?

                            J Offline
                            J Offline
                            Jendker
                            wrote on last edited by Jendker
                            #13

                            @mrjj
                            Yes, it does start without any problem when I am doing it manually. I guess that means, that it has all needed Dlls?

                            I tested and simple console Hello World program is writing to the output file without any problem, but the child QtWidget program which has also std output does not write anything to the file. The problem is that, the program does not terminate, as it is working in loop and is being destroyed before the termination when closing parent application (when starting with start() ). Maybe because of it it does not even write anything to the output file?

                            EDIT: It is possible that I found the issue, please just let me work on it for now to check it.

                            EDIT2: Yes, it seems, that when I was starting the parent, there was something wrong with semaphore what was blocking the other application to start... I was trying to port the standard C++ project (where it was working fine) to Qt and it seems that I messed something up with it. Sorry for the confusion, if I will have any further problems with it, let me continue to ask in this topic.

                            mrjjM 1 Reply Last reply
                            0
                            • J Jendker

                              @mrjj
                              Yes, it does start without any problem when I am doing it manually. I guess that means, that it has all needed Dlls?

                              I tested and simple console Hello World program is writing to the output file without any problem, but the child QtWidget program which has also std output does not write anything to the file. The problem is that, the program does not terminate, as it is working in loop and is being destroyed before the termination when closing parent application (when starting with start() ). Maybe because of it it does not even write anything to the output file?

                              EDIT: It is possible that I found the issue, please just let me work on it for now to check it.

                              EDIT2: Yes, it seems, that when I was starting the parent, there was something wrong with semaphore what was blocking the other application to start... I was trying to port the standard C++ project (where it was working fine) to Qt and it seems that I messed something up with it. Sorry for the confusion, if I will have any further problems with it, let me continue to ask in this topic.

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by mrjj
                              #14

                              @Jendker said in QProcess starting separate Qt application based on QWidget class:
                              Super. I cross fingers you found it.

                              . Maybe because of it it does not even write anything to the output file?

                              Do you call flush from time to time on the file?
                              Else yes, if it dont terminate , it might never flush/write to the file.

                              I guess that means, that it has all needed Dlls?

                              You can check that by renaming the Qt folder and then try to start it.
                              This way it must use its included dlls and not the one it can find in the Qt folder.

                              J 1 Reply Last reply
                              2
                              • mrjjM mrjj

                                @Jendker said in QProcess starting separate Qt application based on QWidget class:
                                Super. I cross fingers you found it.

                                . Maybe because of it it does not even write anything to the output file?

                                Do you call flush from time to time on the file?
                                Else yes, if it dont terminate , it might never flush/write to the file.

                                I guess that means, that it has all needed Dlls?

                                You can check that by renaming the Qt folder and then try to start it.
                                This way it must use its included dlls and not the one it can find in the Qt folder.

                                J Offline
                                J Offline
                                Jendker
                                wrote on last edited by
                                #15

                                @mrjj
                                Thank your for your input :) My case is solved, therefore I match question as answered.

                                J 1 Reply Last reply
                                1
                                • J Jendker

                                  @mrjj
                                  Thank your for your input :) My case is solved, therefore I match question as answered.

                                  J Offline
                                  J Offline
                                  Juampa
                                  wrote on last edited by
                                  #16

                                  @Jendker I would be nice from you to explain how was resolved.

                                  mrjjM 1 Reply Last reply
                                  0
                                  • J Juampa

                                    @Jendker I would be nice from you to explain how was resolved.

                                    mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #17

                                    @Juampa
                                    Hi and welcome the forums.
                                    Which part of the pretty long post ?
                                    You try start a Qt application with Process ?

                                    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