Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. how to use C++ connect method when qmlRegister is applied?
Forum Update on Monday, May 27th 2025

how to use C++ connect method when qmlRegister is applied?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 293 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • johnson54J Offline
    johnson54J Offline
    johnson54
    wrote on last edited by aha_1980
    #1

    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

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      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.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      4

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved