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

Classes QAction/QActionGroup moved from QtWidgets to QtGui miss methods menu() and setMenu()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 6.1.2
    • PySide
    • None
    • c85df0b37c (pyside/pyside-setup/dev) e7d5b521d4 (pyside/pyside-setup/6.2) e7d5b521d4 (pyside/tqtc-pyside-setup/6.2) c85df0b37c (pyside/tqtc-pyside-setup/dev) c85df0b37c (pyside/pyside-setup/6.3) c85df0b37c (pyside/tqtc-pyside-setup/6.3)

    Description

      This has been already discussed on the mailing list, I just copy/paste the original conversation:

      Hi,

      while porting to PySide6 I stumbled over this statement in the Qt docs:

      """

      QAction, QActionGroup

      These classes have been moved into the QtGui <https://doc.qt.io/qt-6/qtgui-module.html> module. Member functions that depend on types defined in QtWidgets <https://doc.qt.io/qt-6/qtwidgets-module.html> (such as QAction::menu() and QAction::setMenu()) are implemented as templates that will be instantiated only when called.

      """

      It seems that the menu() function is not available in PySide6, is this correct? Is there a workaround for this missing functionality, or a plan when it will be added? I've read nothing about this in the porting section of PySide6.

      Thanks for bringing this up, after the changes in QAction*
      we didn't notice we would be missing those methods.

      The short answer is:
      we would see how we can handle this special case,
      since it require more thinking on the binding generations side of things.

      The long answer:

      Due to the changes in QAction (moved from Widgets to Gui)
      we have the case where classes are forward declared (in C++),
      this can be workaround with shiboken declaring custom-types
      with the names of the required types.
      In the past, we used this trick with classes in QtMultimediaWidgets
      that were used as arguments in functions in QtMultimedia,
      so we were able to forward declare them, and they were recognized.

      The problem here is that we don't only need to know the QMenu type,
      but also we need to handle that type, because the functions
      setMenu(QObject*) and menu() needs to be manually added on the typesystem (mainly because we don't have the ability to enable
      them at instance time), and then we need to property convert
      QMenu form C++ to Python, knowing more than the type name (which is
      what we get with the forward declaration).

      We might address this by writing helper functions, that somehow handle
      the special situation, but I'm not sure if it's possible without
      too many hacks.

      Dr. Cristián Maureira-Fredes

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            bdev a dev
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes