在我的 Windows 10 机器上,我正在尝试一些简单的新 Qt6 示例,并且基于 QML 的示例对我不起作用。
我正在运行 Python 3.8.6 和虚拟环境
python3 -m venv venv
.\venv\Scripts\Activate.ps1
pyside6 在没有任何警告的情况下安装到 venv
pip install pyside6
和一个使用 QApplication 和 QLabel 的非 QML hello world 示例运行良好(这个:https ://doc.qt.io/qtforpython/tutorials/basictutorial/widgets.html )
这个例子不起作用,取自https://doc.qt.io/qtforpython/tutorials/basictutorial/qml.html:
主要.py:
from PySide6.QtWidgets import QApplication
from PySide6.QtQuick import QQuickView
from PySide6.QtCore import QUrl
app = QApplication([])
view = QQuickView()
url = QUrl("view.qml")
view.setSource(url)
view.show()
app.exec_()
视图.qml:
import QtQuick 2.0
Rectangle {
width: 200
height: 200
color: "green"
Text {
text: "Hello World"
anchors.centerIn: parent
}
}
我收到的尝试运行的消息是:
file:///C:/github/aorcl/python-gui-2/view.qml:1:1: Cannot load library C:\github\aorcl\python-gui-2\venv\lib\site-packages\PySide6\qml\QtQml\WorkerScript\workerscriptplugin.dll: The specified module could not be found.
import QtQuick
^
file:///C:/github/aorcl/python-gui-2/view.qml: Failed to load dependencies for module "QtQml" version 6.0
file:///C:/github/aorcl/python-gui-2/view.qml: Failed to load dependencies for module "QtQuick" version 6.0
我验证并且文件没有丢失,它在那里:
C:\github\aorcl\python-gui-2\venv\lib\site-packages\PySide6\qml\QtQml\WorkerScript\workerscriptplugin.dll
我还缺少什么?