[Qt-interest] Need some help about QLineEdit

Andre Somers andre at familiesomers.nl
Sun Oct 16 13:13:21 CEST 2011


Op 16-10-2011 13:05, Zeljko schreef:
> Andre Somers wrote:
>
>> Op 16-10-2011 11:06, Zeljko schreef:
>>> Hi,
>>> As I can see there's no way to catch copy(),paste() and cut() ops with any
>>> event/signal ?
>>> I need to intercept those to know when user copied , pasted and
>>> cutted data from QLineEdit and QTextEdit and eventually forbid operation.
>>> I know that QValidator helps in case of paste() , but what about copy() and
>>> cut() ?
>>> Is there any solution (or even planned in 5.0) for such problem (of course
>>> there's + selection copy under X11 ...) ?
>>>
>> You should try an event filter, and filter out the key events.
> I can do that for user input events eg. pressed Ctrl +C , but what about context
> menu actions ? When user triggers copy() via context menu (default one) there's
> no events in event filter that shortcut triggered (Ctrl + C) or anything
> similar.
>
You can show your own context menu, right? You can listen to the 
contextMenuEvent, or use the QWidget::contextMenuPolicy to change if and 
how a context menu is shown.

André




More information about the Qt-interest-old mailing list