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

pyside2-uic and QtCore.QMetaObject.connectSlotsByName

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Out of scope
    • Affects Version/s: 5.9, dev
    • Fix Version/s: None
    • Component/s: PySide
    • Labels:

      Description

      pyside2-uic generates this code:

      class Ui_FormBase(object):
          def setupUi(self, FormBase):
              FormBase.setObjectName("FormBase")
              FormBase.resize(794, 653)
      
              ...
              QtCore.QMetaObject.connectSlotsByName(FormBase)
      

      but in python is "easy" to add widgets and methods at runtime to classes using metaclasses. In this scenario the call to QtCore.QMetaObject.connectSlotsByName is done too early. It's FormBase that should call connectSlotsByName on itself when the form is "complete", if needed.

      In fact calling connectSlotsByName on the same widget multiple times duplicates connections and this leads to multiple slots calls. This could be also a bug by itself: since names are unique in a class I expect unique connections from connectSlotsByName or, at least, a way to tell connectSlotsByName to use Qt::UniqueConnection

      A retro-compatible solution could be adding a command line option to pyside2-uic that disables the call to QtCore.QMetaObject.connectSlotsByName in setupUi.

       

        Attachments

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

          Activity

            People

            • Assignee:
              ctismer Christian Tismer
              Reporter:
              memento_mori Filippo Santovito
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes