Hi guys,
I have recently concentrated on events, and would like to ask ths question:
I have an application of which, mainly, only the trayicon is visible; Howcan I count keyboard/mouse events when the app is running?
Thanks,
Kacper
Hi guys,
I have recently concentrated on events, and would like to ask ths question:
I have an application of which, mainly, only the trayicon is visible; Howcan I count keyboard/mouse events when the app is running?
Thanks,
Kacper
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
Am not sure what u mean by count events.
But have u looked at installing event filters ?? or QWidget::event function ?
Hi,
I have read almost all about events from docs/examples/labs/centre, but I need to filter all events in the event loop (main event loop created by qApp->exec()). If I am going to set a filter on the mainwindow, but the mainwindow will be closed for most of the time, and only the trayicon will be active all the time, will I really get all mouse/keyboard events counted ?
Is there a way to filter all events comming to the main event loop?
Kacper
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
You can install an event filter on the application object itself - this will give you access to all events passed to all objects in the application. But on the other hand I'm not sure if you will get any events at all if you don't have a window active.
Hope you're wrong : )But on the other hand I'm not sure if you will get any events at all if you don't have a window active.
I belive that the application will get every event, but not all will be handled/send due to not active window, but no speculation needed, I will test it right away.
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
Unfortunately for me, you seem to be right : (
It looks like that I should use platform specifis code to count mouse/key events.
Any idea howto do this? I need to work it out for mac os X, linux, windows.
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
For windows you need something that is called a hook, for Unix you need to politely ask X11 to send you all events (don't ask me how) and for Mac... I have no idea
Thanks for the hints.
Someone said that mac os x is the hardest os to count events but surely can be done.
So... I go to hooks/x11 and mac "sth".
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
Have you investigated QAbstractEventDispatcher::setEventFilter()? Not sure how this works on the Mac, but that, combined w/ the OS-specific event filter on QApplication may be what you need.
My experience using this is primarily windows-focused up to this point, and I found that I can get my hands on everything, albeit in an OS-specific way.
Then again, mouse/key data is directed to a specific destination (window), so I guess perhaps the more pertinent question is, whose mouse/key messages are you trying to get?
As wysota pointed out, if what you're really looking for is capturing all user input on the entire desktop, you're in for a very platform- (and even desktop-) specific task. In Windows, a hook is the usual mechanism, but having some experience with those, all I can say is caveat emptor. You're dealing with an extremely sensitive part of the system there.
Bookmarks