Important: Please read the Qt Code of Conduct -

[Solved] Singleton Signal Propogation Question

  • Hi,

    I decided to write a c++ class to handle asynchronous database queries. I registered it with my QML application as a singleton. The c++ class emits a signal when the results are ready and I use the QML "connection" type to target the database object in my component and specify the signal handler. That works great, but what if I have several different components in my QML file that need database access? I submit the query from a particular component and the signal comes back that the results are ready, but all of the components that have a signal handler for that signal get called. I guess I could associate an id with each query submission and then return that id with the signal and ignore that signal in handlers where I don't want to process those results. Is there a better way?

    thnx for you thoughts.


  • I went with my own solution setting an id for each query that I make to the db and then checking that id to restrict signal handling to a particular handler.

Log in to reply