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 to check signal emit finished in python

How to check signal emit finished in python

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 3.3k 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.
  • R Offline
    R Offline
    Ravi_exact
    wrote on last edited by
    #1

    Hi,
    I have created one signal in python using pyside. I'm connecting with that signal 3 times with 3 different methods. when i emit this signal, it has to execute these 3 methods.
    It works perfectly fine.

    ValueChanged = QtCore.Signal(list)

    ValueChanged.connect(method1)
    ValueChanged.connect(method2)
    ValueChanged.connect(method3)

    valueChanged.emit([1,2,3])

    But i would like to know anyway that 3 methods have been executed or not, i.e the status of signal ( signal is in emitting state, emitted state ).
    a) I don't prefer putting bool flag in every methods and track it. b) i can't put some regular interval also bz each method would take its own time.

    How do i know signal emitted all connected methods ?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      There is QSignalSpy in Qt. I'm not sure about python equivalent. Please check if this helps.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

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

        Hi,

        QSignalSpy is only meant to be used in unit tests not production code.

        That's more a design question: if all method must called why not have method1 calling method2 etc. ?

        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
        0
        • R Offline
          R Offline
          Ravi_exact
          wrote on last edited by
          #4

          Hi. Thanks for reply. Actually i would connect to signal based on some conditions and also not in same place. so I can't call method2 inside method1. Even if i do so, how will i know that this method ( method1) has been executed or not without any bool flag.

          1 Reply Last reply
          0
          • T3STYT Offline
            T3STYT Offline
            T3STY
            wrote on last edited by
            #5

            very simple way: global int variable. Increment it when a method is called. When 3, all three methods have been called. Clear the variable whenever a method is called and the variable is 3.
            As simple as that. Is it fine for you?

            Also, I'm not sure if anything can go wrong but once a signal is emitted all slots connected to it will be called sooner or later. So maybe, if you say these you connect to those signals based on conditions, you need something to track whether the slots were actually connected to the signal instead of tracking if all slots are triggered by the signal. This sounds like failure-ready design to me and I would definitely look for an alternative solution.

            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