0
我有我的簡單PyQt5應用程序,其中包括QML文件。我想爲應用設置Material style,但它返回錯誤。QML + PyQt5 Material Style
import QtQuick 2.3
import QtQuick.Controls 2.1
import QtQuick.Window 2.2
import QtQuick.Controls.Material 2.1
ApplicationWindow{
title: qsTr('Qml app')
id: mainWindow
width: 500
height: 400
color: '#f6f6f6'
}
我該如何解決?幫助我,請我 Python代碼是:
import sys
import PyQt5
from PyQt5 import QtWidgets
from PyQt5.QtQuick import QQuickView
if __name__ == '__main__':
myApp = PyQt5.QtWidgets.QApplication(sys.argv)
engine = PyQt5.QtQml.QQmlApplicationEngine()
ctx = engine.rootContext()
ctx.setContextProperty('main',engine)
engine.load('styles/mat.qml')
win = engine.rootObjects()[0]
win.show()
sys.exit(myApp.exec_())
和錯誤消息:
回溯(最近通話最後一個):
文件 「C:\我的\ Python的programms的\ app8.py」,行12,在
贏= engine.rootObjects()[0]
IndexError:列表索引超出範圍
我使用Python 2.7
什麼是錯誤信息? – eyllanesc
什麼是你的python代碼? – eyllanesc
編輯您的文章,並添加您的代碼 – eyllanesc