<div dir="ltr"><div><div><div>Based on Matic's post on StackOverflow (<a href="https://stackoverflow.com/q/72943053/2001654">https://stackoverflow.com/q/72943053/2001654</a>), I believe I can understand the reason for this: having a custom QWidgetAction that *also* acts as an item for a submenu.<br><br></div>I realize this is quite a "fringe" case, but it also seems reasonable.<br></div><div>For instance, imagine a group of non-exclusive checkable actions, and you have a menu that has a submenu for that group (without overflowing the parent menu), with its action item that is also able to show that "some" actions in that group are checked. As we know, QActions don't support partially checked states, so the only available option (yet) is to use a QWidgetAction.<br></div><div>There are other cases that would require this, and (but, please, tell me if I'm terribly wrong) the setMenu is still the easier solution.<br></div><div><br></div><div>While it's possible to override QMenu/QStyle to do so, it seems a bit of an overshoot: what to do with dynamic menus? What if I just want to add an action to an existing menu (such as the standard menu created for text widgets)? What if the menu was created in Designer (yes, I know, promoted widgets, but... is it really necessary for something like this?)<br></div><br></div><div>As stated in the (controversial) discussion of the answer to that post, I agree that the main problem possibly resides in Qt, which should bring back that feature in some way. Still, as far as I can understand, it's also available through the C++ API, so currently the problem is the implementation in the binding.</div><div><br></div><div>Maurizio<br><br></div><div>PS: I don't know if the author of the answer to that post is reading this; if you are, I want to remark that there was absolutely no bad intention/critic to your answer, it was just a sane discussion between people who may *just* disagree, without any judgment, no personal grudge, nor even any assumption or prejudice on knowledge or experience.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno dom 17 lug 2022 alle ore 20:02 Dmitry Shachnev <<a href="mailto:mitya57@ubuntu.com">mitya57@ubuntu.com</a>> ha scritto:<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 all,<br>
<br>
On Sun, Jul 17, 2022 at 11:02:20AM +0100, Phil Thompson wrote:<br>
> On 12/07/2022 17:55, Matic Kukovec wrote:<br>
> > Hi Phil,<br>
> > <br>
> > In Qt5 there were QAction::menu/QAction::setMenu methods for setting a<br>
> > menu on an action,<br>
> > but in Qt6 these are templates. Could there be a workaround for this in<br>
> > PyQt6?<br>
> > PySide seems to have done it:<br>
> > <a href="https://bugreports.qt.io/browse/PYSIDE-1627" rel="noreferrer" target="_blank">https://bugreports.qt.io/browse/PYSIDE-1627</a><br>
><br>
> This comes up from time to time but not with any sense of urgency which<br>
> suggests to me that there is another way of doing things - particularly as<br>
> those methods were deprecated in Qt v6.0.<br>
<br>
For actions in a menu, one can simply use a nested QMenu and addMenu method.<br>
<br>
For actions in a toolbar, one can use QToolButton which has setMenu method<br>
(working in PyQt6).<br>
<br>
--<br>
Dmitry Shachnev<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div>