我正在将项目从 MFC 迁移到 Qt,它使用的是嵌入式 Web 浏览器,它显示本地(资源)html 页面。本地页面显示正常,没有问题。但是我在将 html 内容设置为子标签时遇到问题。 QWebView 无法显示通过 javascript $("#").html() 设置的外部图像 - 仅显示文本和本地(资源)图像。在带有 IE webview 的 MFC 版本中,相同的脚本工作正常。
我试过使用 QWebElement::setInnerXml,但结果是一样的:只显示本地内容。
之后我尝试使用 QWebFrame::setHtml,但是在调用应用程序在 QWebPuginDatabase::searchPathes 某处崩溃后,尽管我从主线程调用 QWebFrame::setHtml。
有人遇到同样的问题吗?有没有人解决我的问题?
谢谢
最佳答案
您可能需要更改设置,尝试:
QWebSettings::globalSettings()->setAttribute(
QWebSettings::LocalContentCanAccessRemoteUrls, true);
QWebSettings
文档描述了 attribute作为(强调我的):
Specifies whether locally loaded documents are allowed to access remote urls. This is disabled by default. For more information about security origins and local vs. remote content see QWebSecurityOrigin.
关于javascript - QWebView无法显示通过javascript设置的外部图片内容 $ ("#<node_name>".html(<html_content>),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8939850/