Problems with Open-Source Downloads read and

[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:
    import sys

    from PyQt5.QtCore import pyqtProperty, QCoreApplication, QObject, QUrl
    from PyQt5.QtQml import qmlRegisterType, QQmlComponent, QQmlEngine

    class ConnectToQml(QObject):

    def __init__(self, parent=None):
        super(ConnectToQml, self).__init__(self)
        self._var = "Hello"
    def variable(self):
        return self._var

    app = QCoreApplication(sys.argv)
    qmlRegisterType(ConnectToQml, 'CQ', 1, 0, 'ConnectToQml')

    engine = QQmlEngine()
    component = QQmlComponent(engine)

    person = component.create()@
    @// Filename: qmlSide2.qml
    import QtQuick 2.0
    import CQ 1.0

    Rectangle {
    width: 400
    height: 400
    Text {
    id: myText
    text: connectToQml.variable
    anchors.horizontalCenter: parent.horizontalCenter
    ConnectToQml {
    id: connectToQml

Log in to reply