Solved QProcess starting separate Qt application based on QWidget class
-
@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. -
@Jendker
Hi
If you go to the location of the application and click it.
Does it then start normally ? -
@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.
-
@Jendker said in QProcess starting separate Qt application based on QWidget class:
, the window did not appear.
Window being a console (cmd) window ?
-
@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. -
@Jendker
it must be something simple then.
The program you trying to start do have a complete deployment folder with all needed Dlls? -
@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.
-
@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. -
@mrjj
Thank your for your input :) My case is solved, therefore I match question as answered. -
@Jendker I would be nice from you to explain how was resolved.
-
@Juampa
Hi and welcome the forums.
Which part of the pretty long post ?
You try start a Qt application with Process ?