【发布时间】:2017-11-02 12:37:00
【问题描述】:
我正在尝试通过 Qt 的“DesktopServices”类使用默认应用程序打开一个 pdf 文件。
但我想出了一个 ShellExecute
'file:///C:/PMPS/PMPSv1/Instuctionsforuse.pdf' failed (error 2). problem.
这是我的代码:
#include <QDesktopServices>
#include <QUrl>
}
void Dialog::guideButtonClicked()
{
QDesktopServices::openUrl(QUrl("file:///C:/PMPS/PMPSv1/Instuctionsforuse.pdf"));
}
【问题讨论】:
-
试试:
QDesktopServices::openUrl(QUrl:::fromLocalFile("C:/PMPS/PMPSv1/Instuctionsforuse.pdf")); -
仍然出现同样的错误:ShellExecute 'file:///C:/PMPS/PMPS??v1/Instuctionsforuse??.pdf' failed (error 2)。
-
试试
QDesktopServices::openUrl(QUrl:::fromLocalFile("C://PMPS//PMPSv1//Instuctionsforuse.pdf")); -
或
QDesktopServices::openUrl(QUrl:::fromLocalFile("C:\\PMPS\\PMPSv1\\Instuctionsforuse.pdf")); -
还是一样的错误...