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. How does a signal know that slot has succesfully executed? Does signals and slots or connect() return any value?
Forum Updated to NodeBB v4.3 + New Features

How does a signal know that slot has succesfully executed? Does signals and slots or connect() return any value?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 972 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.
  • H Offline
    H Offline
    highlander
    wrote on last edited by highlander
    #1

    I am a Qt noob. I would like to know whether a slot returns any value such that we can cross check or verify? Please also do let me know about some good Qt debugging tools and methods to learn more about Qt.

    1 Reply Last reply
    0
    • CarLoowwwwC Offline
      CarLoowwwwC Offline
      CarLoowwww
      wrote on last edited by
      #2

      using qDebug() << "Your message"; inside your slot function?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        connect will return true or false based on a successful connection. However if you use the new Qt 5 syntax, any error in the connect statement will result in a build failure.

        If you would like to have a slot return a value then I'd recommend using the Q_INVOKABLE and use QMetaObject::invokeMethod. In the end that will use the same mechanics as calling a slot but with the benefit that your code will be way clearer to understand. Also, developers that will be using your code later (yourself included) will thank you for the clear separation between slots and invokable methods.

        Slots usually don't have return type, because that would be pretty hazardous in a threaded environment even though you have the possibility to use Qt::BlockingQueuedConnection. When starting to use thread you usually would like to avoid blocking the calling thread. In such an environment, you would rather start processing something in that other thread and at the end signal that the processing is done so the original calling thread (or another one) grabs the result either using a signal parameter or some getter function.

        If you would like to learn more about Qt's internal then you should read KDAB's and Woboq's blogs about Qt as well as dive into the source code.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2

        • Login

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