QStackedWidget and key events
Hi all!
I'm developing a GUI application for a ARM9 based telephone. Presently I write codes and debug under Qt creator 2.1.0 at x86 Ubuntu host. I want to test the application with a conventional USB keyboard connected to a host and later implement all necessary hardware stuff for the embedded platform..
My application has a number of pages created by QStackedWidget. I switch between pages like Menu, Address Book, Parameters etc by pressing QPushButton's. A mouse works fine but I want to use a keypad of a PC-keyboard to handle the necessary logic of the application.
I have a few problems and need your assistance:
1) how should I implement an input system for my application because I need also to scroll letters inputed by a multiple numeric pressings (imaging a cell phone with a keypad, not touchscreen)? I mean if a user enters a Name or a Password he has only "0-9" keys and needs to enter "My_Password123" to some QLineEdit
2) as I have a number of pages with different widgets included how I should capture key events? I try to use keyPressEvent but it depends on a widget being focused, however I need to capture all key event independently to a widget focus.
In fact I can implement a little hack: don't use QWS_KEYBOARD variable and just open a device node "/dev/input/event0" and parse input events manually. This is very easy because Linux input system is trivial. Upon this scenario I don't understand how to translate my acquired events to an Qt-application readable format. In fact I need something like the suggested hack because all numbers have to be translated to letters..
This is my first Qt application and my customer craves for it :mad:
Please help!
Re: QStackedWidget and key events
Quote:
1) how should I implement an input system for my application because I need also to scroll letters inputed by a multiple numeric pressings (imaging a cell phone with a keypad, not touchscreen)? I mean if a user enters a Name or a Password he has only "0-9" keys and needs to enter "My_Password123" to some QLineEdit
I would expect that the phone does the "book keeping" for which letter to deliver, and that the application only gets the current letter pressed.
Make sure you really have to implement this functionality.
Quote:
2) as I have a number of pages with different widgets included how I should capture key events? I try to use keyPressEvent but it depends on a widget being focused, however I need to capture all key event independently to a widget focus.
You can have a key event handler class that filters all key events - see QObject::installEventFilter() - the exmples there also deals with key events.
Re: QStackedWidget and key events
Thank you very much for your answer!
Quote:
Originally Posted by
high_flyer
I would expect that the phone does the "book keeping" for which letter to deliver, and that the application only gets the current letter pressed.
Make sure you really have to implement this functionality.
can you clarify this? I don't understand what you mean
Quote:
You can have a key event handler class that filters all key events - see
QObject::installEventFilter() - the exmples there also deals with key events.
this class seems to have what I need but in the suggested examples they install a filter for every widget, while I need some first handler which will have a necessary state machine and whatever to handle keypad buttons. Any suggestions?
Re: QStackedWidget and key events
Quote:
can you clarify this? I don't understand what you mean
From you question I understood that you want to keep track of how many times a button has been clicked (while in text input mode) to that you know which letter need to be plotted.
I think (but don't know) that this logic should be handled by the device, and that the device should deliver a key press event with the currnte letter.
The only thing I am saying is, make sure you really are the one that need to implement this, and not the device.
Quote:
while I need some first handler which will have a necessary state machine and whatever to handle keypad buttons. Any suggestions?
in that case have a look at QApplication::qwsEventFilter().
Re: QStackedWidget and key events
I'm trying to find any example how to implement qwsEventFilter() but with no luck. Can anybody provide any example?