使用了 setUrl Load方法沒一點反應,顯示的是本地html html同級有js檔案夾,里面是PDFObject.main.js顯示pdf
使用sethtml除錯輸出有顯示,最后卡在 PDFObject未定義的問題上,解決不了。網頁用chrome打開能正常顯示pdf
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>在線瀏覽PDF</title>
</head>
<body>
<script type="text/javascript" src="https://bbs.csdn.net/topics/js/pdfobject.min.js"></script>
<script>
PDFObject.embed("D:/visual3D/WorkstationMultiuser/Builder/Debug/report/Data/1.2.840.113704.1.111.5488.1521071043.1/2019-10-11_15-45.pdf");
</script>
</body>
</html>
pdf絕對路徑,相對路徑都試了
呼叫代碼
ui->webEngineView->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
QString path = "D:/visual3D/WorkstationMultiuser/Builder/Debug/report/Data/view.html";
//ui->webEngineView->load(QUrl(path));
//return;
QFile file(path);
bool isok = file.open(QIODevice::Text | QIODevice::ReadOnly);
QByteArray htmldata = file.readAll();
file.close();
QString ans = QString(htmldata).toUtf8();
ui->webEngineView->setHtml(ans);
報錯資訊
js: Uncaught ReferenceError: PDFObject is not defined
[112320:83780:1021/182104.568:INFO:CONSOLE(12)] "Uncaught ReferenceError: PDFObject is not defined", source: data:text/html;charset=UTF-8,%3C%21DOCTYPE%20html%3E%0A%3Chtml%3E%0A%20%C2%A0%20%C2%A0%3Chead%3E%0A%20%C2%A0%2
使用sethtml以exe為當前目錄
uj5u.com熱心網友回復:
已經將pdf和html和js上傳了,只要能在Qt中打開HTML并顯示就可以了https://pan.baidu.com/s/1nSVcZM-wZF9SUiG9IzmVQQ
主要是手工用瀏覽器打開正常,Qt打開js可能有問題
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/95602.html
標籤:Qt
上一篇:SpringBoot+Netty+WebSocket實作訊息發送
下一篇:Settings.Global.WIFI_DISPLAY_ON, Cannot resolve symbol 'WIFI_DISPLAY_ON'的問題求助
