因为目前的程序需要提供一个文件对比的功能,而目前已经有专门的文本对比软件,所以我打算直接调用外部的文本对比程序。
通过查阅QT的帮助文档,发现了QProcess这个类可以提供这种需求。
我找到的启动外部程序的方法有以下两种:
1、start()
void QProcess::start ( const & program, const & arguments, mode = ReadWrite )
Starts the program program in a new process, passing the command line arguments in arguments. The is set to mode. will immediately enter the Starting state. If the process starts successfully, will emit (); otherwise, () will be emitted.
Note that arguments that contain spaces are not passed to the process as separate arguments.
Windows: Arguments that contain spaces are wrapped in quotes.
Note: Processes are started asynchronously, which means the () and () signals may be delayed. Call () to make sure the process has started (or has failed to start) and those signals have been emitted.
See also (), (), and ().
2、使用QProce