[Qt-interest] Capture mouse Event

Alexandre Beraud aberaud at infflux.com
Thu Jan 29 11:26:55 CET 2009


Hi,

Read this:
http://doc.trolltech.com/4.4/qobject.html#installEventFilter
It is well documented. Briefly, you just tell the qApp that whenever it 
receives an event, it should pass it through its eventFilter() function. 
It could also be the (virtual) function eventFilter() of another 
QObject. That's the point of QObject::installEventFilter(QObject *)

Regards,

Alex


Ankit Agarwal a écrit :
> Hi Ivan,
> Thanks for the reply.
> I have never worked with the event filter thing. Can you please give 
> an example or where can i get an example on that.
>
> On Thu, Jan 29, 2009 at 3:41 PM, Ivan Kharin <korsar.akvis at gmail.com 
> <mailto:korsar.akvis at gmail.com>> wrote:
>
>     > Ankit.
>
>     > Hi,
>     > I have my GUI made in Qt. The app has multiple views(pages).
>     > Problem:
>     > If the user is not performing any operation for a specified amount
>     > of time, say 10 min, then i need to exit the application. How
>     can i achive this?
>
>     > One way of doing this is reimplement mouseMoveEvent() for every
>     > view I have, and then maintain a timer. every time the user moves
>     > the mouse, the timer resets. If the timer expires, then the
>     application exits.
>     > Is there a bteer way to implement the same.
>
>     0. Declare variable: int idleMinutes = 0;
>     1. Set event filter to qApp
>     2. In event_filter body, reset idleMinutes to zero if event is
>     QInputEvent (keyboard or mouse)
>     3. Set QTimer with one minute interval
>     4. In timer_slot body, increment idleMinutes and call qApp->quit()
>     if idleMinutes >= 10
>
>     --
>     Ivan Kharin
>
>     _______________________________________________
>     Qt-interest mailing list
>     Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
>     http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
>
> -- 
> Regards,
> Ankit Agarwal
> SW Engineer
> Vegayan Systems
> email : ankit_agarwal at vegayan.com <mailto:ankit_agarwal at vegayan.com>
> Blog : http://ankit17.wordpress.com
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   


-- 
BERAUD Alexandre
Ingénieur Développement

Infflux - Informatique & Flux
Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
Mail: aberaud at infflux.com
Visitez notre site :  www.infflux.com





More information about the Qt-interest-old mailing list