标题:QProcess如何打开EXCEL?[已解决]
作者:yanzhuliang
日期:2011-03-04 11:14
内容:
QProcess::startDetached(tr("c:\\test.xls"));
这么干貌似不行,有牛人用过吗,给点提示,不胜感激!
bool QProcess::startDetached ( const QString & program, const QStringList & arguments )
Starts the program program with the given arguments in a new process, and detaches from it. Returns true on success; otherwise returns false. If the calling process exits, the detached process will continue to live.
Note: Arguments that contain spaces are not passed to the process as separate arguments.
Unix: The started process will run in its own session and act like a daemon.
Windows: Arguments that contain spaces are wrapped in quotes. The started process will run as a regular standalone process.
#1 [yanzhuliang 03-04 11:22]
补充:
我进行了简单测试,返回过来ret=0,error="Unknown error"。测试代码如下:
QProcess process;
bool ret = process.startDetached(tr("c:\\1.xls"));
QString error = process.errorString();
#2 [XChinux 03-04 13:31]
不是这样用的,你应该用QDesktopServices::openUrl(QUrl::fromLocalFile('xxxxxx.xls"));