Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2560

connect wrong argument using PySide2

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.15.2
    • PySide
    • None
    • Win10 Python3.8.8 PySide2==5.15.2.1
    • Windows

      • Background
        • We use PySide2 to develop many kind of tools in one repo.
        • We want to track all user behavior by tracking all signals or slots.
        • We can get all signals or slots by using app.allWidgets(), and we want to connect these signals to a new function to record to our database.
      • Problem
        • Core code as below.
        • app = QApplication(sys.argv + ["--no-sandbox"])
          window = MainWindow()
          window.show()
          
          for widget in app.allWidgets():
              meta_object = widget.metaObject()
             for i in range(meta_object.propertyCount()):
                 property = meta_object.property(i)
               if not property.hasNotifySignal():
                   continue
               signal = property.notifySignal() 
               widget.connect(widget, signal, record)  # record is our callable function
        • When we run the codes, it failed and show unsupported signatures as below. 
        • We have checked the cpp code, it seems QMethMethod.methodSignature() is QByteArray, not bytes.
        • So we change the last line code below.
        • widget.connect(widget, signal.methodSignature().data(), record) 
        • Then new errors with wrong argument as below.
        • I have print the type of argument, and it seems match (print results show True True True).
        • print(
              isinstance(widget, QObject),
             isinstance(signal.methodSignature().data(), bytes),
             isinstance(record, typing.Callable)
          ) 
      • Other
        • Bugs as above, we have attach the code.
        • If any other methods can meet the requirements for tracking all signals, you can tell me.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            crmaurei Cristian Maureira-Fredes
            tuzhen301 tu zhen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes