比如一个C:/x.csv,就用系统关联的打开方法打开,就像ShellExcute的效果
我找了一下:
QProcess *process;
process=new QProcess;
QString string("C:\\flashxp\\flashfxp.exe");
if(!process->startDetached(string))
{
QMessageBox::warning(this,tr("erro"),tr("%1").arg(process->error()),QMessageBox::Ok);
}
主要注意的有两点:
1、转义字符,在盘符后面的一定是"\\",,而不是“\”。
2、在string里面的路径不能有空格。
以上两点错误在编译的时候不会出错,但是检测一下process erro就会发现出来了,出错的结果是:5,不知名的错误。
这种方法只能打开exe文件.
qt怎么调用windows api:ShellExecute