我使用 Yocto 配方在 Raspberry Pi 2 上编译并安装了 QtWebEngine + QML 插件 tutorial using Yocto dizzy
branch并运行以下脚本:
root@raspberrypi2:~# more chromium.qml
import QtQuick 2.1
import QtQuick.Controls 1.1
import QtWebEngine 0.9
ApplicationWindow {
width: 1280
height: 720
color: "lightgray"
visible: true
WebEngineView {
id: webview
url: "file:///home/root/hello.html"
anchors.fill: parent
}
}
请注意,导入版本是 0.9,而不是 1.0
我已经尝试了 url: "file:///home/root/hello.html"
和 url: "https://duckduckgo.com"
但是我所得到的只是一个带有黑色方形鼠标指针的红色屏幕。
root@raspberrypi2:~# more hello.html
<html>
<header><title>This is title</title></header>
<body>
Hello world
</body>
</html>
在控制台上:
root@raspberrypi2:~# /usr/bin/qt5/qmlscene -v -platform eglfs chromium.qml
[0605/163256:WARNING:resource_bundle.cc(280)] locale_file_path.empty()
[0605/163257:WARNING:proxy_service.cc(890)] PAC support disabled because there is no system implementation
[0605/163257:WARNING:resource_bundle.cc(280)] locale_file_path.empty()
PAC 支持已禁用...
似乎不是问题 read here
更新
我已关注this step-by-step tutorial (Poky fido
branch)然后在我的 Yocto 镜像中添加 qtwebengine
(这次导入 QtWebEngine 1.0
)和 qtwebengine-qmlplugins
并使用 bitbake 再次创建我的镜像
当我启动并运行 /usr/bin/qt5/qmlscene -v -platform eglfs chromium.qml
时,我可以看到我的 HTML 页面。
我测试了几十个网站,但并非所有页面都显示。所以他们可能会更多一点。
例如
http://wikipedia.com shows!!!
http://google.com doesn't show ???
http://https://stackoverflow.com/ shows!!!
http://facebook.com doesn't
欢迎大家指点
更新20160309
root@raspberrypi2:~/app# uname -a
Linux raspberrypi2 4.1.10 #1 SMP PREEMPT Wed Feb 17 16:51:44 CET 2016 armv7l GNU/Linux
root@raspberrypi2:~/app# lsb_release -a
LSB Version: core-4.1-noarch:core-4.1-arm
Distributor ID: poky
Description: Poky (Yocto Project Reference Distro) 2.0.1
Release: 2.0.1
Codename: jethro
QML
root@raspberrypi2:~/app# more chromium.qml
import QtQuick 2.1
import QtQuick.Controls 1.1
import QtWebEngine 1.0
ApplicationWindow {
width: 800
height: 600
color: "lightgray"
visible: true
WebEngineView {
id: webview
//url: "http://raspberrypi.stackexchange.com/" // PASS
//url: "http://google.com" // FAIL
//url: "http://video.webmfiles.org/big-buck-bunny_trailer.webm" // PASS but no Sound
//url: "https://youtube.com/" // FAIL
//url: "https://opentokrtc.com/anybots" // FAIL
//url: "http://speedof.me/" // PASS
url: "http://facebook.com" // FAIL
anchors.fill: parent
}
}
最佳答案
也许有点晚了,但我尝试在 Qt 5.6 alpha 中构建 QtWebEngine,并且它在 Raspberry Pi 2 上对您列出的所有 URL 都能正常工作。这是demo 。也许他们修复了 QtWebEngine 中的某些内容,因此您可以尝试 5.6-alpha。
关于qt5 - 在 Raspberry Pi 2 上运行简单的 QtWebEngine 应用程序,页面未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30682749/