![]() ![]() |
Apr 5 2004, 06:30 PM
Post
#1
|
|
![]() Group: Members Posts: 191 Joined: 16-March 04 From: Indianapolis Member No.: 2,346 |
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. |
|
|
|
Apr 5 2004, 09:29 PM
Post
#2
|
|
|
Group: Members Posts: 280 Joined: 17-March 04 From: Osaka, Japan Member No.: 2,375 |
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. |
|
|
|
Apr 5 2004, 11:46 PM
Post
#3
|
|
![]() Group: Members Posts: 451 Joined: 27-November 03 From: Brisbane, Australia Member No.: 1,001 |
You might also possibly want to look at QPEApplication::grabKeyboard() and QPEApplication::ungrabKeyboard()
|
|
|
|
Apr 6 2004, 03:15 AM
Post
#4
|
|
|
~ Group: Admin Posts: 596 Joined: 2-February 04 From: Cape Canaveral, FL Member No.: 1,667 |
Ha, on the front page, the title is 'Capture Harware Butt'
sorry.. just found it amusing |
|
|
|
Apr 6 2004, 05:16 AM
Post
#5
|
|
![]() Group: Members Posts: 191 Joined: 16-March 04 From: Indianapolis Member No.: 2,346 |
Thanks guys. I got it, now I'm going to try cranking out another app for golf scores.
Touche dz. |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 24th May 2013 - 01:11 PM |