Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, July 2007
Shortcut in QAction in QMenu as context menu


Message 1 in thread

Hello,
I'm using a QAction with a shortcut ('Del').
I add the action to a QMenu and then use exec. The shortcut is shown but
it doesn't work.

Is this a bug?

Regards,
Paul

--
 [ signature omitted ] 

Message 2 in thread

> I'm using a QAction with a shortcut ('Del').
> I add the action to a QMenu and then use exec. The shortcut is shown but
> it doesn't work.
>
> Is this a bug?

The shortcut of a QAction triggers only when it's added to a visible
and enabled widget. This means that the shortcut will not work if the
action is added only to a context menu which is visible only when
requested. Try adding the action to any arbitrary widget which is
always visible. A good choice is the widget which provides the context
menu. :) See QWidget::addAction() for more details.

-- 
 [ signature omitted ] 

Message 3 in thread

I can't understand.
- Why the QMenu shows the shortcut if it's not available.
- How I can diable the shurtcut display in the context menu if it doesn't work.
- The QAction is in a QMenu of the QMainWindow and the shortcut works
when the context menu is not visible. How I can make the trick to make
it work when the context menu is visible.

I think that this behavior is a bug. The short cut shouldn't be
displayed if it doesn't work.

Regards,
Paul

On 7/20/07, J-P Nurmi <jpnurmi@xxxxxxxxx> wrote:
> > I'm using a QAction with a shortcut ('Del').
> > I add the action to a QMenu and then use exec. The shortcut is shown but
> > it doesn't work.
> >
> > Is this a bug?
>
> The shortcut of a QAction triggers only when it's added to a visible
> and enabled widget. This means that the shortcut will not work if the
> action is added only to a context menu which is visible only when
> requested. Try adding the action to any arbitrary widget which is
> always visible. A good choice is the widget which provides the context
> menu. :) See QWidget::addAction() for more details.
>
> --
> J-P Nurmi
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

--
 [ signature omitted ] 

Message 4 in thread

A QMenu doesn't react to shortcuts by the time it's visible but it
does still react to mnemonics:
91023 - Context menu accelerators don't work:
http://trolltech.com/developer/task-tracker/index_html?method=entry&id=91023

By the time the menu is not visible, shortcuts work as long as
corresponding actions are added to visible widgets.

-- 
 [ signature omitted ] 

Message 5 in thread

Thank you for your help.

I can't belive that this is a 'feature'.

Regards,
Paul

On 7/20/07, J-P Nurmi <jpnurmi@xxxxxxxxx> wrote:
> A QMenu doesn't react to shortcuts by the time it's visible but it
> does still react to mnemonics:
> 91023 - Context menu accelerators don't work:
> http://trolltech.com/developer/task-tracker/index_html?method=entry&id=91023
>
> By the time the menu is not visible, shortcuts work as long as
> corresponding actions are added to visible widgets.
>
> --
> J-P Nurmi
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

--
 [ signature omitted ]