Help - Search - Members - Calendar
Full Version: Capture Harware Button Events in Qtopia?
OESF Portables Forum > Everything Else > Archived Forums > Distros, Development, and Model Specific Forums > Zaurus - Everything Development > Qt/Qtopia
Hey any Qtopia experts out there can tell me how to capture the hardware button events in a the rocker button(s) mainly?

Any example code?

You probably will want to take a look at QWidget::keyPressEvent():

Also maybe QObject::eventFilter():

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.
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-2018 Invision Power Services, Inc.