• 11923阅读
  • 2回复

QProcess如何打开EXCEL?[已解决] [复制链接]

上一主题 下一主题
离线yanzhuliang
 

只看楼主 倒序阅读 楼主  发表于: 2011-03-04
QProcess::startDetached(tr("c:\\test.xls"));
这么干貌似不行,有牛人用过吗,给点提示,不胜感激!

bool QProcess::startDetached ( const QString & program, const QStringList & arguments ) [static]
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.
[ 此帖被yanzhuliang在2011-03-05 15:47重新编辑 ]
离线yanzhuliang

只看该作者 1楼 发表于: 2011-03-04
补充:
我进行了简单测试,返回过来ret=0,error="Unknown error"。测试代码如下:

QProcess process;
bool ret = process.startDetached(tr("c:\\1.xls"));
QString error = process.errorString();
[ 此帖被yanzhuliang在2011-03-04 13:11重新编辑 ]
离线XChinux

只看该作者 2楼 发表于: 2011-03-04
不是这样用的,你应该用QDesktopServices::openUrl(QUrl::fromLocalFile('xxxxxx.xls"));
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
快速回复
限100 字节
 
上一个 下一个