Help - Search - Members - Calendar
Full Version: Capture Harware Button Events in Qtopia?
OESF Forums > Distros, Development, and Model Specific Forums > Everything Development > Qt/Qtopia
doc
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.
ashikase
You probably will want to take a look at QWidget::keyPressEvent():
http://doc.trolltech.com/2.3/qwidget#0a4482

Also maybe QObject::eventFilter():
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.
lpotter
You might also possibly want to look at QPEApplication::grabKeyboard() and QPEApplication::ungrabKeyboard()
dz
Ha, on the front page, the title is 'Capture Harware Butt'

sorry.. just found it amusing
doc
Thanks guys. I got it, now I'm going to try cranking out another app for golf scores.

Touche dz.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.