[SOLVED] PyQt5 connect to QML (Question)
-
hi guys
i have this error in connecting PyQt5 to QML :
QQmlComponent: Component is not ready
(i really need this connection)
i have this program (please guide me and tell me my mistakes):
@# Filename: pythonSide2.py
import sysfrom PyQt5.QtCore import pyqtProperty, QCoreApplication, QObject, QUrl
from PyQt5.QtQml import qmlRegisterType, QQmlComponent, QQmlEngineclass ConnectToQml(QObject):
def __init__(self, parent=None): super(ConnectToQml, self).__init__(self) self._var = "Hello" @pyqtProperty('QString') def variable(self): return self._var
app = QCoreApplication(sys.argv)
qmlRegisterType(ConnectToQml, 'CQ', 1, 0, 'ConnectToQml')engine = QQmlEngine()
component = QQmlComponent(engine)
component.loadUrl(QUrl('qmlSide2.qml'))person = component.create()@
and
@// Filename: qmlSide2.qml
import QtQuick 2.0
import CQ 1.0Rectangle {
width: 400
height: 400
Text {
id: myText
text: connectToQml.variable
anchors.horizontalCenter: parent.horizontalCenter
}
ConnectToQml {
id: connectToQml
}
}@