Important: Please read the Qt Code of Conduct -

Reference Errors

  • Hi,

    I have the following problem: I get the following errors at startup of my QML application:

          qrc:/CustomScreen.qml:14:5: QML Connections: Cannot assign to non-existent property "onCustomSignal"
         qrc:/CustomScreen2.qml:15: ReferenceError: customObject is not defined
         qrc:/CustomScreen3.qml:54: ReferenceError: customModel is not defined

    I suppose this happens because I set these properties from C++ only after the application start. What is the correct way of dealing with things, e.g. a model which only get created during the application?

  • Moderators

    You need to initialize the model before you load your QML files - with some default / empty values if you don't yet have the "proper" ones. Then QML engine won't complain.

    Alternatively, you can defer loading the CustomScreenX components by using a Loader (or Qt.createComponent()) and only load them when your data is ready.

Log in to reply