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. [SOLVED] QProcess starting but not showing
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QProcess starting but not showing

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.0k 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.
  • S Offline
    S Offline
    skissmann
    wrote on last edited by
    #1

    Hello!

    Hopefully I'm not missing something simple here but when I attempt to use QProcess with cmd.exe, it starts the process but does not display. Some code:

    @QProcess *process = new QProcess();
    process->setProgram("cmd");
    process->start();
    if(process->state() != QProcess::NotRunning)
    process->waitForFinished(-1);@

    This seems to work correctly when using process->startDetached(); I'm using Qt 5.2 on Windows 7. Any help would be great, thanks!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      What do you expect to see?
      cmd.exe does not spawn any windows and without external help it will not display anything.
      You can read an output of cmd.exe using "readAllStandardOutput":http://qt-project.org/doc/qt-5/qprocess.html#readAllStandardOutput or other read functions and then display it in your window or put it to logfile.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        skissmann
        wrote on last edited by
        #3

        As far as I know, cmd.exe spawns a black DOS command line window for user interaction. What do you mean by "external help" for it to display?

        Just adding to the information, cmd.exe runs in background without doing anything and without showing the command line window.

        Thanks for the reply!

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          You don't see new DOS window when you try to run cmd.exe as child of your process because your program already has a MainWindow and Windows does not create new MainWindow. But when you spawn cmd.exe as detached process without parent then Windows provides new MainWindow.

          If you would like to see the output or enter some input of the application inside your program you need to read stdout, stderr and write to stdin of the application.

          cmd.exe does not do anything by itself. It waits for user input from stdin and will produce some output to stdout or stderr.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            skissmann
            wrote on last edited by
            #5

            I understand, I did not know that cmd was different to other executables, such as calc.exe spawning a window. I'll have to find a way to block the main process even if the cmd.exe is started detached. Thank you for your 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