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. use qmlRegisterType() while able to connect to another object's slots
QtWS25 Last Chance

use qmlRegisterType() while able to connect to another object's slots

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 208 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.
  • C Offline
    C Offline
    cheetahxspeed
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Padlock
      wrote on last edited by Padlock
      #2

      I'm not 100 % sure I understood the question correctly but I don't think there's anything wrong with using setContextProperty () to expose a class to QML.

      1 Reply Last reply
      0

      • Login

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