我试图通过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"));
}发布于 2017-11-02 12:57:24
如果您的Url中已经有处理程序(如file://等),或者如果您的Url已经被编码,并且应该在没有任何转换和更改的情况下使用,那么使用QUrl::fromUserInput函数。当字符串还不是有效的URL时,执行最佳猜测,做出各种与web相关的假设。
QUrl localfile = QUrl::fromUserInput("file:///C:/PMPS/PMPSv1/Instuctionsforuse.pdf"); 您可以检查以下内容是否正确:
qDebug() << localfile.toLocalFile();https://stackoverflow.com/questions/47075501
复制相似问题