我怀疑这是非常基本的,以至于没有人费心去记录它。
我想从我的程序中编写一个 HTML 文件,然后将该文件加载到 QWebview 对象中。
当我打开 QtCreator 时,我可以导航到右侧 URL 块中的文件,它会显示在 QtCreator 中。当我编译并运行程序时,窗口是白色和空白的。
我也不希望目录硬编码,我希望它使用当前目录。
所以我想有两个问题:
ui->reportView->load(QUrl("???"));
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_CTX_new
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function ERR_get_error
谢谢你。
最佳答案
来自网络
webView->load(QUrl("http://google.de"));
来自资源
webView->load(QUrl("qrc:///sample.html"));
从文件系统
webView->load(QUrl("file:///C:/sample.htm"));
不需要
QUrl::FromLocalFile
,不需要 webView->show()
不客气!
关于qt - 如何在 QWebview 中显示本地 HTML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9712315/