PyQt5.5 vs QML vs C++ QML Plugin under Windows (7 or 10) path problems

  • Hi to all. I wrote Path problems in the topic title because I am 99% sure that it depends from something in the path settings. I have three objects:

    • QML main that PyQt5 will set and read a data type
    • Python test that just creates the type and manages it
    • C++ QML Plugin that do some graph calculations used by QML element
    • QML Graphic document that uses the C++ Qt Plugin

    With these elements the scenario is the following:

    Main-Folder =>
     LiveData-Folder => main.qml and LiveData.qml
                    LiveData-Folder => QML components
                                    => C++ QtPlugin dll
                                    => qmldir

    Considered separately, the program correctly connects with main.qml and get the data types.
    When launched by QMLScene the LiveData.qml works fine.

    If I try to join the two parts and launch the the python reports syntax errors related to the wrong import of components.

    Here there are the most meaningful parts of the sources trying to complete the description of the issue. Any help of suggestion is welcome :)

    import sys
    from PyQt5.QtCore import pyqtProperty, QCoreApplication, QObject, QUrl
    from PyQt5.QtQml import qmlRegisterType, QQmlComponent, QQmlEngine
    # This is the type that will be registered with QML.  It must be a
    # sub-class of QObject.
    class LDSetType(QObject):
        def __init__(self, parent=None):
            super(LDSetType, self).__init__()
            # Initialise the value of the properties.
            self._name = ''
        # Define the getter of the property.
        def name(self):
            return self._name
        # Define the setter of the 'name' property.
        def name(self, name):
            self._name = name
    # Create the application instance.
    app = QCoreApplication(sys.argv)
    # Register the Python type.  Its URI is 'PyQtLiveGraph', it's v1.0 and the type
    # will be called 'LDSet' in QML.
    qmlRegisterType(LDSetType, 'PyQtLiveGraph', 1, 0, 'LDSet')
    # Create a QML engine.
    engine = QQmlEngine()
    engine.addImportPath("imports") # last try for test with no results...
    # Create a component factory and load the QML script.
    component = QQmlComponent(engine)
    if component.status() == component.Error:
        # Print the value of the properties.
        myComponent = component.create()
        print("The myComponent's name is %s." %


    import QtQuick 2.2
    import PyQtLiveGraph 1.0
    LDSet {
        name: "QML Type data"
    Rectangle {
        visible: true
        width: 640
        height: 480

    Just in this very simple case, also without using the C++QML Plugin the mentioned problem arises:

    When I launch the command >python the console response is syntax error to the line of the Rectangle object definition. The only QML that works correctly is the the following main.qml:

    import QtQuick 2.2
    import PyQtLiveGraph 1.0
    LDSet {
        name: "QML Type data"
    //Rectangle {
    //    visible: true
    //    width: 640
    //    height: 480

    Running the command >python from the Python folder the result is the following ( is the real name of

    **C:\Python27\python.exe "C:/Users/B.../PyQtLiveGraph/"

    The myComponent's name is QML Type data.**

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.