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 Updated to NodeBB v4.3 + New Features

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.
  • J Offline
    J Offline
    johnson54
    wrote on 23 Apr 2019, 02:44 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
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 23 Apr 2019, 03:07 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

      1/2

      23 Apr 2019, 02:44

      • Login

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