Results 1 to 5 of 5

Thread: QStackedWidget and key events

  1. #1
    Join Date
    Mar 2011
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question 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
    Please help!

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QStackedWidget and key events

    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.
    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Mar 2011
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QStackedWidget and key events

    Thank you very much for your answer!

    Quote Originally Posted by high_flyer View Post
    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
    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QStackedWidget and key events

    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.
    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().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Mar 2011
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default 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?

Similar Threads

  1. QStackedLayout / QStackedWidget
    By morraine in forum Newbie
    Replies: 15
    Last Post: 12th July 2013, 09:16
  2. QTableWidget along with QStackedWidget
    By smiling in forum Qt Programming
    Replies: 5
    Last Post: 13th March 2010, 12:46
  3. Help with QStackedWidget
    By onírico in forum Newbie
    Replies: 6
    Last Post: 12th November 2009, 16:34
  4. Forms or QStackedWidget
    By hgedek in forum Newbie
    Replies: 1
    Last Post: 5th November 2007, 21:35
  5. QStackedWidget question
    By hgedek in forum Qt Programming
    Replies: 3
    Last Post: 20th August 2007, 16:36

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.