我正在关注this教程,并且我遇到了很多QML模块错误。我必须修改为QtQuick.Controls 1.1
,因为2.0, 2.1, 2.3
不起作用。现在这是我的QML:
import QtQuick.Window 2.1
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Material 2.1
现在我只得到
"QtQuick.Controls.Material" is not installed
我使用的是Ubuntu 17.10.1,我的PyQt
报告的版本为5.7
。 Qt的website说:
Import Statement: import QtQuick.Controls.Material 2.3
Since: Qt 5.7
但它不会奏效。由于我有Qt 5.7
我应该能够使用材料设计,因为网站说。但我甚至无法使用QtQuick.Controls 2.x
。
我不想安装Qt 5.8,因为那时我的应用程序不能与旧的Linux兼容。我需要使用5.7。
我应该如何做这项工作?
更新
在尝试使用我的机器并忘记安装的内容后,我创建了一个docker容器来测试它:
FROM ubuntu:latest
ARG SIP_LINK=https://sourceforge.net/projects/pyqt/files/sip/sip-4.19.7/sip-4.19.7.tar.gz
ARG PYQT5_LINK=https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.10/PyQt5_gpl-5.10.tar.gz
RUN apt-get update \
&& apt-get install -y build-essential make wget ca-certificates \
python3 python3-dev \
qt5-default qml-module-qtquick-controls libqt5qml5 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
#SIP INSTALLAITON
RUN wget --progress=bar:force -O sip.tar.gz $SIP_LINK \
&& mkdir sip \
&& tar -xzvf sip.tar.gz -C sip --strip-components=1 \
&& rm sip.tar.gz \
&& cd sip \
&& python3 configure.py && make && make install \
&& cd .. \
&& rm -rf sip
#PYQT5 INSTALLAITON
RUN wget --progress=bar:force -O pyqt5.tar.gz $PYQT5_LINK \
&& mkdir pyqt5 \
&& tar -xzvf pyqt5.tar.gz -C pyqt5 --strip-components=1 \
&& rm pyqt5.tar.gz \
&& cd pyqt5 \
&& python3 configure.py --confirm-license && make && make install \
&& cd .. \
&& rm -rf pyqt5
WORKDIR /home/project
ENTRYPOINT "/bin/bash"
当我这样做时
docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -v /home/lz/project:/home/project -e DISPLAY=unix$DISPLAY test
并且./main.py
(我来自here的main.py之后,我得到了:
root@3054a751f04b:/home/prject# ./main.py
Traceback (most recent call last):
File "./main.py", line 4, in <module>
from PyQt5.QtQml import *
ImportError: No module named 'PyQt5.QtQml'
添加了包qml-module-qtquick-controls libqt5qml5
只是为了让它能够正常运行,但它没有帮助
更新2:
添加包python3-pyqt5.qtquick
后,我现在只得到错误:
QQmlApplicationEngine failed to load component
file:///home/project/main.qml:4 module "QtQuick.Controls.Material" is not installed
process 12: D-Bus library appears to be incorrectly set up; failed to read machine uuid: UUID file '/etc/machine-id' should contain a hex string of length 32, not length 0, with no other text
See the manual page for dbus-uuidgen to correct this issue.
但是,我不应该添加python3 qt包,因为我正在构建它们