You won't notice my mention about setContextProperty... So I am not satisfy with your answer.
Correct answer is that: Yes this is possible in that way:
In order to use pointers variable in Qml you will have to do following steps:
1. Register your class in order to make it understandable to QVariant:
qRegisterMetaType<QSqlQueryModel*>("QSqlQueryModel *");
2. Register your class in Qml:
qmlRegisterType<QSqlQueryModel>("com.shomething", 1, 0, "QSqlQueryModel");
3. Create your variable:
QmlTableModel* lModel2 = new QmlTableModel(this);
4. Get object contains your QSqlQueryModel* property from QQmlApplicationEngine:
QObject* lCallbackObject = findObject(lCallbackObjectName);
5. Set property:
lCallbackObject->setProperty("mModel", QVariant::fromValue(lModel2));
Essential in this procedure is QVariant::fromValue - qVariantFromValue will not work.
I didn't check whether the same works with function calls from C++ to Qml, but it should.
Bookmarks