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

signal connect picks wrong signature if callback has argument defaults

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.11.2
    • PySide
    • None
    • Linux/X11

    Description

      I am able to connect the signal QPushButton.clicked to callbacks with the following signatures:

       

      callback()
      
      callback(x)
      
      callback(x=None)
      
      callback(x, y=None)
      

       

      However only the first three work correctly; in the last case, emitting `clicked` causes an error:

      TypeError: callback() takes at least 1 argument (0 given)

      I have attached an example script that generates this error for me.

      It seems that the optional `y` argument causes the wrong signal overload to be connected (since clicked has both  [void] and [bool] overloads). I encountered this while migrating a large application from PyQt to PySide2, and I am left wondering whether I should wait for this to be fixed, or if this is the intended behavior and I should attempt to correct the application code?

      Might also be nice to have an explanation of how overloads are automatically selected at https://wiki.qt.io/Qt_for_Python_Signals_and_Slots.

       

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            lcampagn Luke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes