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

Qt-interest Archive, May 2007
Copy & paste shortcuts


Message 1 in thread

Hi all,

I'm trying to implement copy & paste functionality for a single widget
(one can only copy/paste items from/to this widget). I tried to create
QActions, set their shortcuts to Ctrl+C and Ctrl+V, then add them to the
widget. Problem is that when I hit the shortcut, northing happens, and
Qt prints 'QAction::eventFilter: Ambiguous shortcut overload: Ctrl+V'.

How can I get this to work?

Thanks,
M

--
 [ signature omitted ] 

Message 2 in thread

How do I list shortcuts in my application? There is indeed another
action associated with the same shortcut, residing in a toolbar. Can't
my 'local' action override this shortcut as long as the associated
widget has the focus?

M


-----Ursprüngliche Nachricht-----
Von: veronique.lefrere@xxxxxx [mailto:veronique.lefrere@xxxxxx]
Gesendet: Dienstag, 15. Mai 2007 11:02
An: Umgeher, Martin
Betreff: Re: Copy & paste shortcuts

did you list shotrcuts in your application?
are you sure that this action is the only one that is associated with
this shortcut?....


QMartin a écrit :

>Hi all,
>
>I'm trying to implement copy & paste functionality for a single widget
>(one can only copy/paste items from/to this widget). I tried to create
>QActions, set their shortcuts to Ctrl+C and Ctrl+V, then add them to the
>widget. Problem is that when I hit the shortcut, northing happens, and
>Qt prints 'QAction::eventFilter: Ambiguous shortcut overload: Ctrl+V'.
>
>How can I get this to work?
>
>Thanks,
>M

--
 [ signature omitted ] 

Message 3 in thread

Try setting  Qt::ShortcutContext to Qt::WidgetShortcut
The shortcut is only triggered when its parent widget has focus.

Yuriy



"QMartin" <martin.umgeher@xxxxxxxxxxx> ???????/???????? ? ???????? 
?????????: news:f2c238$p6r$1@xxxxxxxxxxxxxxxxxxxxx
> How do I list shortcuts in my application? There is indeed another
> action associated with the same shortcut, residing in a toolbar. Can't
> my 'local' action override this shortcut as long as the associated
> widget has the focus?
>
> M
>
>
> -----Ursprüngliche Nachricht-----
> Von: veronique.lefrere@xxxxxx [mailto:veronique.lefrere@xxxxxx]
> Gesendet: Dienstag, 15. Mai 2007 11:02
> An: Umgeher, Martin
> Betreff: Re: Copy & paste shortcuts
>
> did you list shotrcuts in your application?
> are you sure that this action is the only one that is associated with
> this shortcut?....
>
>
> QMartin a écrit :
>
>>Hi all,
>>
>>I'm trying to implement copy & paste functionality for a single widget
>>(one can only copy/paste items from/to this widget). I tried to create
>>QActions, set their shortcuts to Ctrl+C and Ctrl+V, then add them to the
>>widget. Problem is that when I hit the shortcut, northing happens, and
>>Qt prints 'QAction::eventFilter: Ambiguous shortcut overload: Ctrl+V'.
>>
>>How can I get this to work?
>>
>>Thanks,
>>M 


--
 [ signature omitted ] 

Message 4 in thread

Hi,

thanks for your hint. With WidgetShortcut context, no ambiguity warning
is issued, however the other action (the one in the toolbar) is
triggered. It seems to override any shortcut set lower in the hierarchy.
For completeness, that's my code (inside a QWidget subclass):

  new QShortcut(QKeySequence("Ctrl+C"), this, SLOT(copy()), 0,
Qt::WidgetShortcut);

Any other ideas how to enable that shortcut in my widget?

Thanks!
M




Yuriy Soroka wrote:
> Try setting  Qt::ShortcutContext to Qt::WidgetShortcut
> The shortcut is only triggered when its parent widget has focus.
> 
> Yuriy
> 
> 
> 
> "QMartin" <martin.umgeher@xxxxxxxxxxx> ???????/???????? ? ???????? 
> ?????????: news:f2c238$p6r$1@xxxxxxxxxxxxxxxxxxxxx
>> How do I list shortcuts in my application? There is indeed another
>> action associated with the same shortcut, residing in a toolbar. Can't
>> my 'local' action override this shortcut as long as the associated
>> widget has the focus?
>>
>> M
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: veronique.lefrere@xxxxxx [mailto:veronique.lefrere@xxxxxx]
>> Gesendet: Dienstag, 15. Mai 2007 11:02
>> An: Umgeher, Martin
>> Betreff: Re: Copy & paste shortcuts
>>
>> did you list shotrcuts in your application?
>> are you sure that this action is the only one that is associated with
>> this shortcut?....
>>
>>
>> QMartin a écrit :
>>
>>> Hi all,
>>>
>>> I'm trying to implement copy & paste functionality for a single widget
>>> (one can only copy/paste items from/to this widget). I tried to create
>>> QActions, set their shortcuts to Ctrl+C and Ctrl+V, then add them to the
>>> widget. Problem is that when I hit the shortcut, northing happens, and
>>> Qt prints 'QAction::eventFilter: Ambiguous shortcut overload: Ctrl+V'.
>>>
>>> How can I get this to work?
>>>
>>> Thanks,
>>> M 
> 
> 

--
 [ signature omitted ] 

Message 5 in thread

Well I solved the problem by removing the actions with identical
shortcuts from the toolbar. Still, I'd be interested in a solution that
allows to have toolbar actions as well...



QMartin wrote:
> Hi,
> 
> thanks for your hint. With WidgetShortcut context, no ambiguity warning
> is issued, however the other action (the one in the toolbar) is
> triggered. It seems to override any shortcut set lower in the hierarchy.
> For completeness, that's my code (inside a QWidget subclass):
> 
>   new QShortcut(QKeySequence("Ctrl+C"), this, SLOT(copy()), 0,
> Qt::WidgetShortcut);
> 
> Any other ideas how to enable that shortcut in my widget?
> 
> Thanks!
> M
> 
> 
> 
> 
> Yuriy Soroka wrote:
>> Try setting  Qt::ShortcutContext to Qt::WidgetShortcut
>> The shortcut is only triggered when its parent widget has focus.
>>
>> Yuriy
>>
>>
>>
>> "QMartin" <martin.umgeher@xxxxxxxxxxx> ???????/???????? ? ???????? 
>> ?????????: news:f2c238$p6r$1@xxxxxxxxxxxxxxxxxxxxx
>>> How do I list shortcuts in my application? There is indeed another
>>> action associated with the same shortcut, residing in a toolbar. Can't
>>> my 'local' action override this shortcut as long as the associated
>>> widget has the focus?
>>>
>>> M
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: veronique.lefrere@xxxxxx [mailto:veronique.lefrere@xxxxxx]
>>> Gesendet: Dienstag, 15. Mai 2007 11:02
>>> An: Umgeher, Martin
>>> Betreff: Re: Copy & paste shortcuts
>>>
>>> did you list shotrcuts in your application?
>>> are you sure that this action is the only one that is associated with
>>> this shortcut?....
>>>
>>>
>>> QMartin a écrit :
>>>
>>>> Hi all,
>>>>
>>>> I'm trying to implement copy & paste functionality for a single widget
>>>> (one can only copy/paste items from/to this widget). I tried to create
>>>> QActions, set their shortcuts to Ctrl+C and Ctrl+V, then add them to the
>>>> widget. Problem is that when I hit the shortcut, northing happens, and
>>>> Qt prints 'QAction::eventFilter: Ambiguous shortcut overload: Ctrl+V'.
>>>>
>>>> How can I get this to work?
>>>>
>>>> Thanks,
>>>> M 
>>

--
 [ signature omitted ]