43570

QProcess::startDetached() not show console window

I have a GUI program that start cli program by click button. I want to see console window and don't need wait until cli program end. So I use code like this:

QProcess::startDetached("cmd.exe");

After click button I don't see console window. But see cmd.exe process in task manager.

I tried use system() command but it freeze my app before cli program end.

Is there any way to make window visible?

Answer1:

It is the expected behavior. At least in Windows startDetached is equivalent to calling CreateProcess with the DETACHED_PROCESS flag, where the new process does not inherit its parent's console. It makes sense that in other platforms the method would do something similar.

In this case you'd had to manually allocate a new one using AllocConsole on the new process (be aware that you may need to redirect the streaming handles to the new console), or try to start the process in a different way (check CreateProcess or fork).

BTW, the reason system freezes your application is because it is a synchronous call, so it won't return the control until the other process finishes. You may try calling system from a separate thread and it this way you avoid blocking the main event loop of your application.

Recommend

  • Interacting with actionscript 3.0 using javascript
  • How to protect swf files from being view?
  • How to apply action to mulitple flash layers
  • How to compare 2 arrays?
  • dimensions of loaded swf's stage
  • PHP Sleep Function (Email Throttling) Freezes Entire Server
  • pip freeze lists uninstalled packages
  • jScrollPane causes slow script warning
  • Flash Components with Flex SDK
  • Is there a reliable tool for stepping through code while serving in foreman
  • Accessing another variable in the same class with a click event
  • PyQt4 application on Windows is crashing on exit
  • text-align justify, cannot override
  • Why can't UI components be accessed from a backgroundworker?
  • Compare struct to a constant in C
  • Wrong labels when plotting a time series pandas dataframe with matplotlib
  • How to getText() from the input field of an angularjs Application
  • Android application: how to use the camera and grab the image bytes?
  • how to avoid repetitive constructor in children
  • Should I or shouldn't I use the CachingConnectionFactory with hornetq 2.4.1
  • Saving Changes After In-App Purchase Has Been Purchased
  • CakePHP 2.0.4 - findBy magic methods with conditions
  • PHP buffered output depending on server setting?
  • Functions in global context
  • How to install a .deb file on a jailbroken iphone programmatically?
  • QLineEdit password safety
  • Jenkins: How To Build multiple projects from a TFS repository?
  • req.body is undefined - nodejs
  • How do I fake an specific browser client when using Java's Net library?
  • Is possible to count alias result on mysql
  • Check if a string to interpolate provides expected placeholders
  • Symfony2: How to get request parameter
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Apache 2.4 - remove | delete | uninstall
  • Akka Routing: Reply's send to router ends up as dead letters
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Is there a mandatory requirement to switch app.yaml?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • How does Linux kernel interrupt the application?