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. Adding slots to components dynamically in QML?

Adding slots to components dynamically in QML?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 390 Views 1 Watching
  • 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.
  • D Offline
    D Offline
    Developer123
    wrote on last edited by Developer123
    #1

    Description: I have many components on a parent component root. Each of these components has a property called parameterId. I would like to transmit from the backend different data stream to these components, depending on the parameterId that they have.

    So if parameterId=3, then this component would receive the data stream from the parameter 3, and so on. These components would be created dynamically.

    Solution #1: Have every component connect to a single SIGNAL of type object, as describbed here. Then every component would receive ALL data streams, and they could dynamically select which data to gather using their parameterId as the key to a javascript object in QML.

    I know how to do this, however, this seems it would be somewhat data inefficient, as there could be hundreds of components, receiving hundreds of data points many times per second.

    Solution #2: Have the application create SLOTS for each component, for specific SIGNALS coming from the backend, based on their parameterId, during startup.

    Solution #3: Have the root component connect to a single SLOT containing all the data streams (it receives a javascript object). Then it could call a Javascript function updateValue(data) defined for each component, which updates their value.

    I want to implement Solution #2, but I cannot find anywhere saying how to do this inside QML, or in PySide2. Solution #3 is simpler, but it sounds like a "hack", and not the right way to do this (?)

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      I would use a model view approach. Then use the various "view" items from qml with c++ models.

      C++ is a perfectly valid school of magic.

      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