[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: PyQt6: Missing QAction.setMenu or equivalent
From:       RoadrunnerWMC <roadrunnerwmc () gmail ! com>
Date:       2021-04-21 19:51:59
Message-ID: CADLpnNvGEwV7H_XtV+gH5FzM_AOwP5KXRrgJ_5FnR5ATErywQg () mail ! gmail ! com
[Download RAW message or body]

Nice idea; that does work in PyQt6. Thanks.

On Wed, Apr 21, 2021 at 2:47 PM Dmitry Shachnev <mitya57@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
>

[Attachment #3 (text/html)]

<div dir="ltr">Nice idea; that does work in PyQt6. Thanks.</div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 21, 2021 at 2:47 PM \
Dmitry Shachnev &lt;<a href="mailto:mitya57@ubuntu.com">mitya57@ubuntu.com</a>&gt; \
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">On Wed, Apr 21, 2021 \
at 02:26:59PM -0400, RoadrunnerWMC wrote:<br> &gt; That&#39;d work in that particular \
case, but it&#39;s still a problem that there&#39;s<br> &gt; (as far as I know) no \
way to implement the following common pattern in<br> &gt; PyQt6:<br>
&gt;<br>
&gt; recent_menu = QtWidgets.QMenu()<br>
&gt; recent_menu.addAction(&#39;foo.py&#39;)<br>
&gt; recent_menu.addAction(&#39;bar.txt&#39;)<br>
&gt; recent_menu.addAction(&#39;baz.png&#39;)<br>
&gt;<br>
&gt; menu = main_window.menuBar().addMenu(&#39;&amp;File&#39;)<br>
&gt; menu.addAction(&#39;Open...&#39;)<br>
&gt; menu.addAction(&#39;Open Recent&#39;).setMenu(recent_menu)<br>
<br>
I think you can use:<br>
<br>
recent_menu = QtWidgets.QMenu(&#39;Open Recent&#39;)<br>
<br>
and then simply:<br>
<br>
menu.addMenu(recent_menu)<br>
<br>
--<br>
Dmitry Shachnev<br>
</blockquote></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic