1.用QT的QAxWidget展示PDF。
QAxWidget* officeContent = new QAxWidget(this);;
QString filename = "1.pdf";
officeContent= new QAxWidget("Microsoft Web Browser");
QVariant v = officeContent->dynamicCall("Navigate(const QString&)", filename);
备注:需要安装PDF阅读器。
2.用调用Adobe Radar打开(不起作用时(只出现黑色背景,打不开文件),用1方法)。
QString filename = "1.pdf";
QAxWidget* officeContent = = new QAxWidget(this);
if (!officeContent ->setControl("Adobe PDF Reader"))
{
//未安装Adobe Radar
}
officeContent->dynamicCall("LoadFile(const QString&)",filename);
备注:需要安装Aoble Radar。
3.直接在浏览器中打开。
QString filename = "1.pdf";
QDesktopServices::openUrl(QUrl::fromLocalFile(filename ));