要安装哪个模块来修复 Yocto 的 "module QtQuick.Controls.Styles is not installed" 错误?
Which module to install to fix "module QtQuick.Controls.Styles is not installed" error for Yocto?
我已经在 this tutorial 之后成功地为 RPi2 构建了一个 Yocto 图像。我决定扩展 QML 演示并尝试一些 Qt 快速样式 (import QtQuick.Controls.Styles 1.4
)。
这是图像的 bb
文件
# Pulled from a mix of different images:
include recipes-core/images/rpi-basic-image.bb
# This image is a little more full featured, and includes wifi
# support, provided you have a raspberrypi3
inherit linux-raspberrypi-base
SUMMARY = "The minimal image that can run Qt5 applications"
LICENSE = "MIT"
# depend on bcm2835, which will bring in rpi-config
DEPENDS += "bcm2835-bootfiles"
MY_TOOLS = " \
qtbase \
qtbase-dev \
qtbase-mkspecs \
qtbase-plugins \
qtbase-tools \
"
MY_PKGS = " \
qt3d \
qt3d-dev \
qt3d-mkspecs \
qtcharts \
qtcharts-dev \
qtcharts-mkspecs \
qtconnectivity-dev \
qtconnectivity-mkspecs \
qtquickcontrols2 \
qtquickcontrols2-dev \
qtquickcontrols2-mkspecs \
qtdeclarative \
qtdeclarative-dev \
qtdeclarative-mkspecs \
qtgraphicaleffects \
qtgraphicaleffects-dev \
"
MY_FEATURES = " \
linux-firmware-bcm43430 \
bluez5 \
i2c-tools \
python-smbus \
bridge-utils \
hostapd \
dhcp-server \
iptables \
wpa-supplicant \
"
DISTRO_FEATURES_append += " bluez5 bluetooth wifi"
IMAGE_INSTALL_append = " \
${MY_TOOLS} \
${MY_PKGS} \
${MY_FEATURES} \
basicquick \
"
# Qt >5.7 doesn't ship with fonts, so these need to be added explicitely
IMAGE_INSTALL_append = "\
ttf-dejavu-sans \
ttf-dejavu-sans-mono \
ttf-dejavu-sans-condensed \
ttf-dejavu-serif \
ttf-dejavu-serif-condensed \
ttf-dejavu-common \
"
和演示本身的 bb
文件
SUMMARY = "Simple Qt5 Quick application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
# I want to make sure these get installed too.
DEPENDS += "qtbase qtdeclarative qtquickcontrols2"
SRCREV = "${AUTOREV}"
# GitLab own repo
SRC_URI[sha256sum] = "f2dcc13cda523e9aa9e8e1db6752b3dfaf4b531bfc9bb8e272eb3bfc5974738a"
SRC_URI = "git://git@gitlab.com:/some-repo.git;protocol=ssh"
S = "${WORKDIR}/git"
require recipes-qt/qt5/qt5.inc
do_install() {
install -d ${D}${bindir}
install -m 0755 BasicQuick ${D}${bindir}
}
执行时出现错误
QQmlApplicationEngine failed to load component
qrc:/main.qml:24 Type Page2 unavailable
qrc:/Page2.qml:4 module "QtQuick.Controls.Styles" is not installed
其中 Page2
是我在 main.qml
中定义和使用的项目。该演示在我的 PC(自定义构建的 Qt 5.9.1)上运行没有任何问题,但由于缺少子模块而在 RPi2 上运行失败。
坦率地说,我以前从未使用过这个子模块(我定制的 Qt 5.9.1 启用了所有功能)并且我不确定我需要包括什么(如果 meta-qt5
甚至提供它)以便能够在 Yocto 系统上使用它。
问题是 Qt Quick Controls 包的版本不匹配。
您使用版本 1:
import QtQuick.Controls.Styles 1.4
但构建版本 2:
MY_PKGS = " \
...
qtquickcontrols2 \
...
您需要在图像中包含的内容是 qtquickcontrols
。
您需要安装qtquickcontrols-qmlplugins。
只需添加到 build/local.conf
PACKAGECONFIG_append_pn-qtbase = " accessibility"
PACKAGECONFIG_append_pn-qtquickcontrols = " accessibility"
IMAGE_INSTALL_append = " qtdeclarative-qmlplugins qtquickcontrols-qmlplugins"
这是原始手册
https://importgeek.wordpress.com/2018/07/17/module-qtquick-controls-is-not-installed/
我已经在 this tutorial 之后成功地为 RPi2 构建了一个 Yocto 图像。我决定扩展 QML 演示并尝试一些 Qt 快速样式 (import QtQuick.Controls.Styles 1.4
)。
这是图像的 bb
文件
# Pulled from a mix of different images:
include recipes-core/images/rpi-basic-image.bb
# This image is a little more full featured, and includes wifi
# support, provided you have a raspberrypi3
inherit linux-raspberrypi-base
SUMMARY = "The minimal image that can run Qt5 applications"
LICENSE = "MIT"
# depend on bcm2835, which will bring in rpi-config
DEPENDS += "bcm2835-bootfiles"
MY_TOOLS = " \
qtbase \
qtbase-dev \
qtbase-mkspecs \
qtbase-plugins \
qtbase-tools \
"
MY_PKGS = " \
qt3d \
qt3d-dev \
qt3d-mkspecs \
qtcharts \
qtcharts-dev \
qtcharts-mkspecs \
qtconnectivity-dev \
qtconnectivity-mkspecs \
qtquickcontrols2 \
qtquickcontrols2-dev \
qtquickcontrols2-mkspecs \
qtdeclarative \
qtdeclarative-dev \
qtdeclarative-mkspecs \
qtgraphicaleffects \
qtgraphicaleffects-dev \
"
MY_FEATURES = " \
linux-firmware-bcm43430 \
bluez5 \
i2c-tools \
python-smbus \
bridge-utils \
hostapd \
dhcp-server \
iptables \
wpa-supplicant \
"
DISTRO_FEATURES_append += " bluez5 bluetooth wifi"
IMAGE_INSTALL_append = " \
${MY_TOOLS} \
${MY_PKGS} \
${MY_FEATURES} \
basicquick \
"
# Qt >5.7 doesn't ship with fonts, so these need to be added explicitely
IMAGE_INSTALL_append = "\
ttf-dejavu-sans \
ttf-dejavu-sans-mono \
ttf-dejavu-sans-condensed \
ttf-dejavu-serif \
ttf-dejavu-serif-condensed \
ttf-dejavu-common \
"
和演示本身的 bb
文件
SUMMARY = "Simple Qt5 Quick application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
# I want to make sure these get installed too.
DEPENDS += "qtbase qtdeclarative qtquickcontrols2"
SRCREV = "${AUTOREV}"
# GitLab own repo
SRC_URI[sha256sum] = "f2dcc13cda523e9aa9e8e1db6752b3dfaf4b531bfc9bb8e272eb3bfc5974738a"
SRC_URI = "git://git@gitlab.com:/some-repo.git;protocol=ssh"
S = "${WORKDIR}/git"
require recipes-qt/qt5/qt5.inc
do_install() {
install -d ${D}${bindir}
install -m 0755 BasicQuick ${D}${bindir}
}
执行时出现错误
QQmlApplicationEngine failed to load component
qrc:/main.qml:24 Type Page2 unavailable
qrc:/Page2.qml:4 module "QtQuick.Controls.Styles" is not installed
其中 Page2
是我在 main.qml
中定义和使用的项目。该演示在我的 PC(自定义构建的 Qt 5.9.1)上运行没有任何问题,但由于缺少子模块而在 RPi2 上运行失败。
坦率地说,我以前从未使用过这个子模块(我定制的 Qt 5.9.1 启用了所有功能)并且我不确定我需要包括什么(如果 meta-qt5
甚至提供它)以便能够在 Yocto 系统上使用它。
问题是 Qt Quick Controls 包的版本不匹配。
您使用版本 1:
import QtQuick.Controls.Styles 1.4
但构建版本 2:
MY_PKGS = " \
...
qtquickcontrols2 \
...
您需要在图像中包含的内容是 qtquickcontrols
。
您需要安装qtquickcontrols-qmlplugins。
只需添加到 build/local.conf
PACKAGECONFIG_append_pn-qtbase = " accessibility"
PACKAGECONFIG_append_pn-qtquickcontrols = " accessibility"
IMAGE_INSTALL_append = " qtdeclarative-qmlplugins qtquickcontrols-qmlplugins"
这是原始手册 https://importgeek.wordpress.com/2018/07/17/module-qtquick-controls-is-not-installed/