Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] PyQt5 connect to QML (Question)
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] PyQt5 connect to QML (Question)

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    madoodia
    wrote on last edited by
    #1

    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 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"
    
    @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.0

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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved