-
Notifications
You must be signed in to change notification settings - Fork 2
Installation
Likianta Me edited this page Dec 19, 2022
·
2 revisions
使用 pip 即可安装:
pip install qmlease当前最新版本是 3.0+.
请注意, 安装了 qmlease 并不包含 qt 库. 你需要自行选择下面其中一个进行安装:
# pip 安装其中之一
pip install pyside6
pip install pyqt6
pip install pyside2
pip install pyqt5qmlease 会自动检测你的 python 环境中安装的 qt 库 (你也可以强制指定一个). 该特性是由 qtpy 提供支持.
qtpy 为 pyside 和 pyqt 提供了一层统一的 API 来调用. 它的导入名称偏向于 pyside 的模块命名规则 (比如, from qtpy.QtCore import Property, Signal, Slot).
当你的 python 环境中安装了多个 qt 库, 想要指定其中一个被使用, 请在导入 qtpy 之前, 设置你的 os.environ 变量:
import os
os.environ['QT_API'] = 'pyside6' # pyside6, pyqt6, pyside2, pyqt5
# 然后, 导入 qtpy
from qtpy import QT_VERSION
from qtpy.QtWidgets import QWidget
print(QT_VERSION) # e.g. '6.4.0'
print(QWidget) # e.g. <class 'PySide6.QtWidgets.QWidget'>