| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 1 | |
Hi all, I'm working with Qt-4.3.4 on Linux (Kde) and I want to handle middle mouse click on a widget without subclassing it. I've installed an event filter on TextEdit but I can't handle middle mouse click. When I click, I get only the standard unix "Paste" action, but the filter is not called. When I double-click the middle-button I get a single clik on eventFilter. Can anyone make this clear to me? What I missed? Stefano Rosellini Informatica Valdinievole
Attachment:
Attachment:
event.zip
Description: Zip archive
Message 2 in thread
Stefano Rosellini wrote:
> I'm working with Qt-4.3.4 on Linux (Kde) and I want to handle middle
> mouse click on a widget without subclassing it.
> I've installed an event filter on TextEdit but I can't handle middle
> mouse click. When I click, I get only the standard unix "Paste" action,
> but the filter is not called. When I double-click the middle-button I
> get a single clik on eventFilter.
> Can anyone make this clear to me? What I missed?
Are you filtering QTextEdit, or its viewport? :-)
Try installing the filter on textEdit->viewport() and see what happens...
--
[ signature omitted ]
Message 3 in thread
Andreas Aardal Hanssen ha scritto:
> Stefano Rosellini wrote:
>
>> I'm working with Qt-4.3.4 on Linux (Kde) and I want to handle middle
>> mouse click on a widget without subclassing it.
>> I've installed an event filter on TextEdit but I can't handle middle
>> mouse click. When I click, I get only the standard unix "Paste" action,
>> but the filter is not called. When I double-click the middle-button I
>> get a single clik on eventFilter.
>> Can anyone make this clear to me? What I missed?
>>
>
> Are you filtering QTextEdit, or its viewport? :-)
>
> Try installing the filter on textEdit->viewport() and see what happens...
>
Yes. It works! Thanks!
It means that when I want to catch some events of a widget I must handle
events for all of it's children. It's true?
--
[ signature omitted ]
Message 4 in thread
> Yes. It works! Thanks!
> It means that when I want to catch some events of a widget I
> must handle events for all of it's children. It's true?
No. But QAbstractScrollArea (and all of the widgets that are derived
from it, like QTextEdit) are special in that they "translate"
mouseclicks depending on the scrolled-to position.
That's why you have to use the viewport instead of the widget.
Cheers,
Peter
--
[ signature omitted ]
Message 5 in thread
Peter Prade ha scritto:
>> Yes. It works! Thanks!
>> It means that when I want to catch some events of a widget I
>> must handle events for all of it's children. It's true?
>>
>
> No. But QAbstractScrollArea (and all of the widgets that are derived
> from it, like QTextEdit) are special in that they "translate"
> mouseclicks depending on the scrolled-to position.
> That's why you have to use the viewport instead of the widget.
>
Ok, now it's clear.
Thanks for the explanation.
Stefano Rosellini
Informatica Valdinievole
--
[ signature omitted ]