Important: Please read the Qt Code of Conduct -

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
    In this way, there will be no explicit declariton of m_A and m_B, and how can I use the 'connect' method?


  • Qt Champions 2017

    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.

Log in to reply