Important: Please read the Qt Code of Conduct -

[SOLVED]Reference from QT is not found in QML / Multiple QML file Communication with QT

  • Hi,
    Is the below code valid !!!

    the issue is im getting an error from QML page--- the reference error :"mainSettings" is not defined.
    but I have defined it. rest every thing is working fine.

    @ QGuiApplication app(argc, argv);
    GUIHandler libSetup;
    settingsPage settings;

    QtQuick2ApplicationViewer viewer;
    QtQuick2ApplicationViewer settingsviewer;

    Im not sure if this helps --- main.qml contains settings component(Settings.qml) in it.

    Please help.

  • Lifetime Qt Champion


    Valid yes, but doesn't work like you think.

    Why are you using two different viewers ? mainSettings is only valid in the context of settingsviewer not in viewer.

  • Oh,
    Sorry I'nt knew that.
    The reason i wanted to use is, I have to call qt function from settings and even I have some properties where settings.qml uses.

    @ boxes.children[i].txtLabel=mainSettings.readBedNoSetup(i+1)@

    and im sending this data to qt for saving in an ini file.

    even this goes same with main.qml but it has its own properties declared in other class.

    is there any other way to handle it.?
    i just need to make settings.qml to talk with qt's (Q_INVOKABLE) methods

  • @
    QQmlEngine engine;
    QQmlComponent component(&engine, QUrl::fromLocalFile("qml/Test1/Settings.qml"));

    Even this did not work.

    Hope I need to go to docs again.
    Mean while, If there is any way please let me know

  • Hi,
    Finally I went through the docs and googled all possible ways and solved the issue.
    Thanks for the Docs provided by QT team.

    The way I solved is by using

    1. Signal-Slot communication b/w QML and QT.
    2. Sharing data b/w QML files with the help of Java Scripts.
    3. inter function accessing b/w QML files.

    when through these docs
    "QML bindings":

    "QML Signals":

    "Extending QML":

Log in to reply