Author Topic: Capture Harware Button Events in Qtopia?  (Read 2556 times)

doc

  • Full Member
  • ***
  • Posts: 191
    • View Profile
    • http://
Capture Harware Button Events in Qtopia?
« 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.
By your command...

Doc
Sharp SL-5500 PDA
Sharp 2.78 ROM
Viking 256MB SD
Socket LP-E CF Ethernet

ashikase

  • Sr. Member
  • ****
  • Posts: 280
    • View Profile
    • http://
Capture Harware Button Events in Qtopia?
« Reply #1 on: April 06, 2004, 01:29:49 am »
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.
SL-C3100 & SL-C760

lpotter

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
    • http://qtopia.net
Capture Harware Button Events in Qtopia?
« Reply #2 on: April 06, 2004, 03:46:32 am »
You might also possibly want to look at  QPEApplication::grabKeyboard() and  QPEApplication::ungrabKeyboard()
Software Engineer, Systems Group, MES, Trolltech
irc.freenode.net #qtopia
http://qtopia.net

dz

  • Administrator
  • Hero Member
  • *****
  • Posts: 589
    • View Profile
    • http://www.dangerz.net
Capture Harware Button Events in Qtopia?
« Reply #3 on: April 06, 2004, 07:15:56 am »
Ha, on the front page, the title is \'Capture Harware Butt\'

sorry.. just found it amusing
http://www.dangerz.net
c860 : Cacko
The greatest experience we can have is the mysterious.
- Albert Einstein

doc

  • Full Member
  • ***
  • Posts: 191
    • View Profile
    • http://
Capture Harware Button Events in Qtopia?
« Reply #4 on: April 06, 2004, 09:16:09 am »
Thanks guys.  I got it, now I\'m going to try cranking out another app for golf scores.

Touche dz.
By your command...

Doc
Sharp SL-5500 PDA
Sharp 2.78 ROM
Viking 256MB SD
Socket LP-E CF Ethernet