OESF Portables Forum
Everything Else => Zaurus - Everything Development => Distros, Development, and Model Specific Forums => Archived Forums => Qt/Qtopia => Topic started by: doc on April 05, 2004, 10:30:27 pm
-
Hey any Qtopia experts out there can tell me how to capture the hardware button events in a program...like the rocker button(s) mainly?
Any example code?
Thanks.
-
You probably will want to take a look at QWidget::keyPressEvent():
http://doc.trolltech.com/2.3/qwidget#0a4482 (http://doc.trolltech.com/2.3/qwidget#0a4482)
Also maybe QObject::eventFilter():
http://doc.trolltech.com/2.3/qobject#bd20fe (http://doc.trolltech.com/2.3/qobject#bd20fe)
If you look around the QObject and QWidget doc pages, you\'ll find an example or two of capturing keys.
One thing to note is that whatever widget is in focus will receive the event first (before its parent). Say you have a QWidget with a QFrame in it, and a QLineEdit inside the QFrame, and the QLineEdit has focus. When you press a key, the QLineEdit will receive the event first. It can then either eat the event (stop it, thus preventing the parent from seeing it) or pass it on to the parent.
Some widgets eat quite a few keystrokes, such as QTable, and the parent never sees them... this is where eventFilter can come in handy. EventFilter can intercept events being sent to another widget.
Hope that helps.
-
You might also possibly want to look at QPEApplication::grabKeyboard() and QPEApplication::ungrabKeyboard()
-
Ha, on the front page, the title is \'Capture Harware Butt\'
sorry.. just found it amusing
-
Thanks guys. I got it, now I\'m going to try cranking out another app for golf scores.
Touche dz.