I have my simple PyQt5 application, which includes QML file. I want set Material style for app, but it returns error.
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'
}
How can I fix it? Help me,please My python code is:
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_())
And the error message:
Traceback (most recent call last):<br>
File "C:\My\Python programms\app8.py", line 12, in <module><br>
win = engine.rootObjects()[0]<br>
IndexError: list index out of range<br>
I am using Python 2.7