engine.rootContext()->setContextProperty change Instance
-
class Cust { }; Cust *c1 = new Cust(); Cust *c2 = new Cust(); Cust *c3 = new Cust(); engine.rootContext()->setContextProperty("cust", c1);
I have a Cust.qml file.
How can i make cust -> c2 or cust -> c3 in Cust.qml ?Thank you!
@neeme You need a new class that presents the same interface as
Cust
but which is implemented by delegating to the active instance ofCust
. In addition, you need a means of selecting the active instance. It is not clear whether you want to control this from QML. If so, then simply add a suitable method to your new class.