I have
qmlRegisterType<DataModel>("one.DataModel", 1, 0, "DataModel");
qmlRegisterType<DataModel>("one.DataModel", 1, 0, "DataModel");
To copy to clipboard, switch view to plain text mode
and I instance this in QML
DataModel {
}
DataModel {
}
To copy to clipboard, switch view to plain text mode
I need to get pointer to the istantiated objct in C++ side. BUT I do not want to use aproach with use of
findChild()
findChild()
To copy to clipboard, switch view to plain text mode
.
How to get a pointer?
I have
qmlRegisterType<DataModel>("one.DataModel", 1, 0, "DataModel");
qmlRegisterType<DataModel>("one.DataModel", 1, 0, "DataModel");
To copy to clipboard, switch view to plain text mode
and I instance this in QML
DataModel {
}
DataModel {
}
To copy to clipboard, switch view to plain text mode
I need to get pointer to the istantiated objct in C++ side. BUT I do not want to use aproach with use of
findChild()
findChild()
To copy to clipboard, switch view to plain text mode
.
How to get a pointer?
Added after 30 minutes:
I got the solution
QObject *dataModel
= engine.
rootObjects()[0]->property
("refToMainModelForC").
value<QObject
*>
();
qDebug() << dataModel << "is address of data model";
QObject *dataModel = engine.rootObjects()[0]->property("refToMainModelForC").value<QObject*>();
qDebug() << dataModel << "is address of data model";
To copy to clipboard, switch view to plain text mode
in QML
property var refToMainModelForC: treeModel
DataModel {
id: treeModel
property var viewCurrentIndex: null
}
property var refToMainModelForC: treeModel
DataModel {
id: treeModel
property var viewCurrentIndex: null
}
To copy to clipboard, switch view to plain text mode
Bookmarks