QT Open External Program
[CPP]View Plaincopy
- 1. By calling system functions
- System ("Opt/myapp"); //This is Linux, under Windows can use WinExec and other functions
- 2. Blocking calls via Qprocess
- Qprocess::execute ("/opt/myapp"); //absolute path and relative path can be, windows with EXE suffix, system applications such as Notepad Notepad can be entered directly open
- 3. Non-blocking calls via Qprocess
- Qprocess *pro = new qprocess;
- Pro->start ("/opt/myapp"); <strong><span style="FONT-SIZE:18PX;" >
- </span></strong>
1. the first two methods block the process until the MyApp program ends, and the third method does not block the process and can run multiple tasks.
2. qt In the run time, to start the QWS service, if using the previous two methods, when running, to open a new qws, otherwise not run, and in the third method, you do not need to open qws, it and the main process share a qws.
3. Although the third method does not block, it is possible that the printed information is not visible on the terminal. Therefore, in order to display information in the terminal, you can consider blocking mode.
4. The third method can be added to the startup parameters, see QT documentation.
Reference: http://blog.csdn.net/u012234115/article/details/46335219
QT Open External Program three methods (two kinds of blocking, one non-blocking)