PyQt6: Missing QAction.setMenu or equivalent
RoadrunnerWMC
roadrunnerwmc at gmail.com
Wed Apr 21 20:51:59 BST 2021
Nice idea; that does work in PyQt6. Thanks.
On Wed, Apr 21, 2021 at 2:47 PM Dmitry Shachnev <mitya57 at ubuntu.com> wrote:
> On Wed, Apr 21, 2021 at 02:26:59PM -0400, RoadrunnerWMC wrote:
> > That'd work in that particular case, but it's still a problem that
> there's
> > (as far as I know) no way to implement the following common pattern in
> > PyQt6:
> >
> > recent_menu = QtWidgets.QMenu()
> > recent_menu.addAction('foo.py')
> > recent_menu.addAction('bar.txt')
> > recent_menu.addAction('baz.png')
> >
> > menu = main_window.menuBar().addMenu('&File')
> > menu.addAction('Open...')
> > menu.addAction('Open Recent').setMenu(recent_menu)
>
> I think you can use:
>
> recent_menu = QtWidgets.QMenu('Open Recent')
>
> and then simply:
>
> menu.addMenu(recent_menu)
>
> --
> Dmitry Shachnev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210421/2580dd4d/attachment-0001.htm>
More information about the PyQt
mailing list