PyQt6: Missing QAction.setMenu or equivalent

Dmitry Shachnev mitya57 at ubuntu.com
Wed Apr 21 18:57:18 BST 2021


Hi,

On Wed, Apr 21, 2021 at 03:58:36PM +0200, Ales Erjavec wrote:
> Hi
>
> In Qt6 QAction was moved to QtGui module and is therefore missing
> `setMenu(QMenu)`, `menu()` , or rather the methods are implemented as
> templates
> that will be instantiated only when called
> (https://doc.qt.io/qt-6/widgets-changes-qt6.html#qaction-qactiongroup).
>
> How do we set a menu on an QAction in PyQt6 since `QAction.setMenu`
> does not exist?

If your use of QAction.setMenu was just to get a drop-down button in the
toolbar (like it was in my case), you can use a QToolButton for this.

Example:

https://github.com/retext-project/retext/commit/daf20c3633dd4a50

--
Dmitry Shachnev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210421/0ab917e3/attachment.sig>


More information about the PyQt mailing list