use qmlRegisterType() while able to connect to another object's slots
-
I am doing interactions with C++ and Qml.
I have a class Client, which Qml will be interact with, and a class Master.
I want to use qmlRegisterType to expose Client into Qml. but the problem is I have to connect Client's signals to Master's slots, so the Master will response to Client's action. To be able to do the connection, I have to create Client object & Master object:
QObject::connect(clientObj, &Client::homeChgd, masterObj, &Master::homeChanged);
But when I call qmlRegisterType<Client>("com.client", 1, 0, "Client"): Client is directly passed to QML, I cannot create its object and then do the connection with Master object.
I am now using setContextProperty() to expose the connected Client object to Qml.
But is there a way to use qmlRegisterType() while still being able to connect to another object's slots? Or I am doing it wrong?
Thank you very much for your help in advance.