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

Would like C++ implicit casting (converting constructors)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 6.1
    • 5.12.0
    • Shiboken
    • None
    • All
    • a45ee7a68e3fbcf99eb31e8a395779cc0a9f3540 (pyside/pyside-setup/dev) 3fd974c11eb60651c09fe65ed41125b517070224 (pyside/pyside-setup/6.1)

    Description

      I think this is a shiboken feature request.  An example is:

      a = QAction()
      a.setShortcut(Qt.Key_Back)
      

      PySide6

      Python 3.8
      Qt 6.2.0 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 9.3.0)
      FIXME Subscripted generics cannot be used with class and instance checks
      Traceback (most recent call last):
        File "pyside907.py", line 25, in <module>
          a.setShortcut(Qt.Key_Back)
      TypeError: 'PySide6.QtGui.QAction.setShortcut' called with wrong argument types:
        PySide6.QtGui.QAction.setShortcut(Key)
      Supported signatures:
        PySide6.QtGui.QAction.setShortcut(Union[PySide6.QtGui.QKeySequence, PySide6.QtCore.QKeyCombination, PySide6.QtGui.QKeySequence.StandardKey, str, int])
      

      PySide2

      Python 3.8
      Qt 5.15.4 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.3.1 20160406 (Red Hat 5.3.1-6))
      Traceback (most recent call last):
        File "pyside907.py", line 25, in <module>
          a.setShortcut(Qt.Key_Back)
      TypeError: 'PySide2.QtWidgets.QAction.setShortcut' called with wrong argument types:
        PySide2.QtWidgets.QAction.setShortcut(Key)
      Supported signatures:
        PySide2.QtWidgets.QAction.setShortcut(PySide2.QtGui.QKeySequence)
      

      In C++, the Key_Back is implicitly converted to a QKeySequence because the QKeySequence constructor takes a QKey as an argument.  Interestingly:

      >>> a.setShortcut(Qt.CTRL + Qt.Key_Plus)

      is okay.

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            gregcouch Greg Couch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes