<div dir="ltr">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:<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">from PyQt5 import QtWidgets<br></font></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">app = QtWidgets.QApplication([])<br>main_window = QtWidgets.QMainWindow()<br></font></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">recent_menu = QtWidgets.QMenu()<br>recent_menu.addAction('foo.py')</font></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">recent_menu.addAction('bar.txt')</font></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">recent_menu.addAction('baz.png')</font></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">menu = main_window.menuBar().addMenu('&File')<br>menu.addAction('Open...')<br>menu.addAction('Open Recent').setMenu(recent_menu)</font></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">menu.addAction('Save')<br>menu.addAction('Save As...')<br></font></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">main_window.show()<br>app.exec_()</font></blockquote></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 21, 2021 at 1:57 PM Dmitry Shachnev <<a href="mailto:mitya57@ubuntu.com">mitya57@ubuntu.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On Wed, Apr 21, 2021 at 03:58:36PM +0200, Ales Erjavec wrote:<br>
> Hi<br>
><br>
> In Qt6 QAction was moved to QtGui module and is therefore missing<br>
> `setMenu(QMenu)`, `menu()` , or rather the methods are implemented as<br>
> templates<br>
> that will be instantiated only when called<br>
> (<a href="https://doc.qt.io/qt-6/widgets-changes-qt6.html#qaction-qactiongroup" rel="noreferrer" target="_blank">https://doc.qt.io/qt-6/widgets-changes-qt6.html#qaction-qactiongroup</a>).<br>
><br>
> How do we set a menu on an QAction in PyQt6 since `QAction.setMenu`<br>
> does not exist?<br>
<br>
If your use of QAction.setMenu was just to get a drop-down button in the<br>
toolbar (like it was in my case), you can use a QToolButton for this.<br>
<br>
Example:<br>
<br>
<a href="https://github.com/retext-project/retext/commit/daf20c3633dd4a50" rel="noreferrer" target="_blank">https://github.com/retext-project/retext/commit/daf20c3633dd4a50</a><br>
<br>
--<br>
Dmitry Shachnev<br>
</blockquote></div>