Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PySide6, Python 3.10 : Issue with Signal.emit only sending one argument :
Forum Updated to NodeBB v4.3 + New Features

PySide6, Python 3.10 : Issue with Signal.emit only sending one argument :

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 2 Posters 1.5k 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.
  • T Offline
    T Offline
    TonySuffolk
    wrote on last edited by
    #1

    I have a Signal defined as a class variable in a custom class :

    Reset_needed = QtCore.Signal(str,str)
    

    and I emit as follows :

    self.Reset_needed.emit(name, connection_id)
    

    Where both name and connection_id are both non-empty strings.

    In another class I have connected to the above signal and the handler takes two arguments : name and cid

    Within the handler name is entirely as expected,, but the cid argument is received as an empty string (ie. only the first argument to emit is used).
    Is this a known issue ?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TonySuffolk
      wrote on last edited by
      #4

      I have managed to identify the issue, and it was a problem deep in my code (not in QT thankfully). In my case everything i had done had lead me to believe that both parameters were strings, but in fact the 2nd parameter cid is in fact an integer, which means that QT type mangling would not have correctly used the str type for it when defining the signal - an easy fix for me.

      Ty to @SGaist for trying to help solve this - it turns out to be a classic PEBCAK error - and the first time in 8 years I have been hit with a real Python type issue (thankfully not in production.

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

        Hi,

        Which version of PySide are you using ?
        Did you decorate the target method with Slot ?
        Please provide a minimal runnable script that shows this issue.

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

        T 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Which version of PySide are you using ?
          Did you decorate the target method with Slot ?
          Please provide a minimal runnable script that shows this issue.

          T Offline
          T Offline
          TonySuffolk
          wrote on last edited by TonySuffolk
          #3

          @SGaist
          I am using PySide6.

          None of the examples I have seen use any sort of decorator on the target function: I will try that.

          I am trying to trim the whole thing into a small example - I will post it as soon as I have it.

          Bizzarely the mininum example works fine, and i can't see the difference between the example and the full version.

          import sys
          
          from PySide6 import QtCore
          from PySide6.QtWidgets import QApplication, QWidget
          
          class Terminal(QtCore.QObject):
              ResetNeeded = QtCore.Signal(str, str)
          
              def __init__(self, name, cid):
                  super().__init__()
                  self._name = name
                  self._cid = cid
          
              def trigger(self):
                  self.ResetNeeded.emit(self._name, self._cid)
          
          class Application(QWidget):
              def __init__(self):
                  super().__init__()
                  self._t1 = Terminal('Production','2363')
                  self._t2 = Terminal('Test','7369')
                  self._t1.ResetNeeded.connect(self.triggered)
                  self._t2.ResetNeeded.connect(self.triggered)
                  self.process()
          
              def triggered(self, name, cid):
                  print(f'{name!r} {cid!r}')
          
              def process(self):
                  self._t1.trigger()
                  self._t2.trigger()
          
          if __name__ == '__main__':
              app = QApplication()
              w = Application()
              w.show()
              sys.exit(app.exec())
          

          The only difference I can see is that in the full version the 'Application' class is not a main window - but is embedded into another window.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            TonySuffolk
            wrote on last edited by
            #4

            I have managed to identify the issue, and it was a problem deep in my code (not in QT thankfully). In my case everything i had done had lead me to believe that both parameters were strings, but in fact the 2nd parameter cid is in fact an integer, which means that QT type mangling would not have correctly used the str type for it when defining the signal - an easy fix for me.

            Ty to @SGaist for trying to help solve this - it turns out to be a classic PEBCAK error - and the first time in 8 years I have been hit with a real Python type issue (thankfully not in production.

            1 Reply Last reply
            0
            • T TonySuffolk has marked this topic as solved on
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #5

              Glad you found out and thanks for sharing !
              Didn't you get a warning for that mismatch at some point ?

              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

              • Login

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