Originally Posted by
wysota
Can you prepare a minimal compilable example demonstrating that you don't have access to methods defined in the C++ model?
Well, that's probably not exactly the case. I CAN access them while I have DIRECT access to my model. But I can't or don't know how I can access them inside of a delegate.
For example I do something like
engine.rootContext()->setContextProperty("testModel", &model);
engine.rootContext()->setContextProperty("testModel", &model);
To copy to clipboard, switch view to plain text mode
And then in qml I can call my "testMethod()" via "testModel.testMethod()" (if it's marked as Q_INVOKABLE of course).
But if I have something like
MyCustomDelegate {
model: testModel
}
MyCustomDelegate {
model: testModel
}
To copy to clipboard, switch view to plain text mode
and in MyCustomDelegate.qml I write model.testMethod(), testMethod or something I get that this property is not a function.
So right now I have something like this:
MyCustomDelegate {
model: testModel
testMethod: testModel.testMethod
}
MyCustomDelegate {
model: testModel
testMethod: testModel.testMethod
}
To copy to clipboard, switch view to plain text mode
where testMethod is var property of my delegate.
Bookmarks