Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Callback and Signal-Slot?

Callback and Signal-Slot?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.0k Views 2 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.
  • c.savurC Offline
    c.savurC Offline
    c.savur
    wrote on last edited by
    #1

    Hello everyone,

    I have question about using both callback and Signal/Slot in a Qt application.

    I have a external library that calling my qt application via callback. In the Qt application as normal I am using Signal and Slot. So in order to not have any problem what is the best way to handle both callback and Signal ?

    Right now, I am handling in following manner,

    1 ) Registering my callback method.
    2 ) when my callback method invoked by library, I generate a signal and return from my callback method.
    3 ) since signal is connected to a slot, it invoke it.

    So far this method is working. But I want see if you have better approach that can handle this station.
    I also want to know if there is a side affect of the approach I am using right now?

    Thanks.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      That's pretty much the standard way to write wrappers for non-Qt mechanisms.

      The only comment I have here is that the order you presented is not quite right. For single threaded programs the default connection is a direct one, meaning that the actual emit is a blocking function calling all the connected slots, so the order is actually:

      1. Registering my callback method.
      2. when my callback method is invoked by library, I generate a signal
      3. since signal is connected to a slot, it invoke it.
      4. return from my callback method.

      So that's something to keep in mind, usually in a context of order of destruction of things.

      c.savurC 1 Reply Last reply
      3
      • Chris KawaC Chris Kawa

        That's pretty much the standard way to write wrappers for non-Qt mechanisms.

        The only comment I have here is that the order you presented is not quite right. For single threaded programs the default connection is a direct one, meaning that the actual emit is a blocking function calling all the connected slots, so the order is actually:

        1. Registering my callback method.
        2. when my callback method is invoked by library, I generate a signal
        3. since signal is connected to a slot, it invoke it.
        4. return from my callback method.

        So that's something to keep in mind, usually in a context of order of destruction of things.

        c.savurC Offline
        c.savurC Offline
        c.savur
        wrote on last edited by
        #3

        @Chris-Kawa

        Hi Chris,

        Actually, I am doing in the same order you wrote. :)

        I will keep this topic, open so see others opinion.

        Thanks

        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