Start an external program from Qt
-
Hello everybody,
ich developped a vision app and now I want to start that app by pushing a button on an Qt gui.
More precise the button is on the MainWindow.
I found a lot of hints in the web but they are not working for me.QProcess * my process = new QProcess();
myprocess-> start("absoulte path", QStreingList() << "Start");
I also used startDetached , but that's also not working.
Does anyboy have an example for me?Thanks a lot.
Kindy regards,
Timo
-
@Timo_F Which platform and Qt version? Any error messages?One of the reasons I could imagine is privilege, if you are doing the task on windows, you need to change the privilege by manifest.
Example of manifest :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> </assembly>
And call the mt.exe, you can save some trouble by adding following lines in .pro
win32 { WINSDK_DIR = C:/Program Files (x86)/Windows Kits/10 WIN_PWD = $$replace(PWD, /, \\) OUT_PWD_WIN = $$replace(OUT_PWD, /, \\) message("output : " + $$OUT_PWD_WIN) QMAKE_POST_LINK = "$$WINSDK_DIR/bin/x86/mt.exe -manifest $$quote($$WIN_PWD\\$$basename(TARGET).manifest) -outputresource:$$quote($$OUT_PWD_WIN\\${DESTDIR_TARGET};1)" }
Maybe the app compiled by mingw do not need to go through this kind of troubles
-
@tham
there are no errors ... it's like death. I'm using Qt 5.8 on Windows10.
Where is the manifest doc? -
@tham
there are no errors ... it's like death. I'm using Qt 5.8 on Windows10.
Where is the manifest doc?@Timo_F said in Start an external program from Qt:
@tham
there are no errors ... it's like death. I'm using Qt 5.8 on Windows10.So you did hook up
http://doc.qt.io/qt-5/qprocess.html#errorOccurred
and see what it says ? -
Thank you all a lot. :-)
Now it works ... shame on me, it was so simple. I copied and paste the path directly from the explorer and that was not working. Replacing the "" by "/" in the path was the solution !!