[Qt] viewportEvent of QAbstractScrollArea
Paul Ishenin
ip at kmiac.ru
Wed Oct 3 02:33:55 CEST 2007
Den Jean wrote:
> I still think it is better to use eventfilter to be able to use
> descendants aswell. But I released V1.52 with this request anyhow.
> http://users.pandora.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html
Ok, how I should install eventFilter to viewPort? Yes, viewport can be
any widget and I can try to do the same as this method do:
procedure TQtObject.AttachEvents;
var
Method: TMethod;
begin
FEventHook := QObject_hook_create(TheObject);
TEventFilterMethod(Method) := @EventFilter;
QObject_hook_hook_events(FEventHook, Method);
end;
But look at QAbstractScrollArea::setViewport
d->viewport->installEventFilter(d->viewportFilter);
So after setViewPort call my eventFilter will be overriden by own qt
eventFilter. So how should I install eventFilter to viewport?
The only way is (hack):
1. call setViewPort
2. install eventFilter after that
Is it right? I think no, since this way is not prefered by qt. They
defined some rules:
"When inheriting QAbstractScrollArea, you need to do the following:
...
* Handle events received by the viewport in viewportEvent() -
notably resize events."
Lest play by their rules, or if we do hacks then we might have troubles
with next version of qt.
If I am wrong in understanding qt or bindings please correct me. I dont
know maybe way wich I see as hack is legal way.
Best regards,
Paul Ishenin.
More information about the Qt
mailing list