[SOLVED]Reference from QT is not found in QML / Multiple QML file Communication with QT
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);
QtQuick2ApplicationViewer viewer; QtQuick2ApplicationViewer settingsviewer; viewer.rootContext()->setContextProperty("libSetup",&libSetup); viewer.setMainQmlFile(QStringLiteral("qml/Test1/main.qml")); settingsviewer.rootContext()->setContextProperty("mainSettings",&settings); settingsviewer.setSource(QStringLiteral("qml/Test1/Settings.qml")); viewer.showFullScreen();@
Im not sure if this helps --- main.qml contains settings component(Settings.qml) in it.
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.
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.
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
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
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
- Signal-Slot communication b/w QML and QT.
- Sharing data b/w QML files with the help of Java Scripts.
- inter function accessing b/w QML files.
when through these docs