如何在pyside中使用Material样式?

How use Material Style in pyside?

我有pyside6应用程序,我想将应用程序的样式设置为Material设计所以我在下面设置sys.argv += ['--style', 'material']:

import sys,os
from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine, qmlRegisterType
from PySide6.QtCore import QObject, Slot, Signal, QTimer, QUrl
import PySide6

if __name__ == "__main__":
    #os.environ['QT_QUICK_CONTROLS_STYLE'] = "material"
    #==================================================
    sys.argv += ['--style', 'material']
    #==================================================
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()
    engine.load(os.path.join(os.path.dirname(__file__), "qml/main.qml"))
    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())

但是我报错:

QQmlApplicationEngine failed to load component
file:///D:/QtProjects/qtforpythonprojects/JooyaTrader01/qml/main.qml: module "material" is not installed

我最近安装了 Qt 6,我使用的是 pyside6

Qt6 中的名称似乎比 Qt5 中的名称更受限制,因此您应该使用“Material”而不是“material”。