how to use C++ connect method when qmlRegister is applied?
-
I'm new to qml, here is my question:
if I have two class, such as class ModelA and class ModelB, they need to communicate
In main.c, I will write as follows:
///
ModelA m_A;
ModelB m_B;
connect(&m_A, SIGNAL(signalFromA()), &m_B, SLOT(slotFromB());
///
However, when I bind qml to ModelA and ModelB, in main.c
///
qmlRegisterType<ModelA>("importNameA",1,0,"nameA");
qmlRegisterType<ModelB>("importNameB",1,0,"nameB");
///
In this way, there will be no explicit declariton of m_A and m_B, and how can I use the 'connect' method?thanks
-
when you do qmlregistertype, you are registering the class. So you need to make the connect where you are creating the objects. I'm assuming that you are creating the objects in QML. So you need to make the connect statement in qml code.