Qt World Summit: Submit your Presentation

5 Keys Input and Menu handling?

  • Hi all,

    I have started with QT and I am a little bit frustrated right now.
    I thought I would be able to use QT 4.8.6 Embedded to develop a LCD GUI with Menus and Input,Combo,Select Boxes, only using a 5 Button Input Key design.

    It looks similiar to this:

    I have tried navigation using connect and the signalmapper, but up down postEvent does not do anything.
    And using the focusNextElement function and previousElement are not in x and y axis, so this is not a good choice ;/

    But I have several issues at the moment:

    • How to navigate with up, down, left ,right in a grid menu?
    • How can I use the input to enter for e.g. a hostname with only a 5 button system?
      I thought i just can use the input and increment/decrement the char?
    • Is there any plugin/help like other embedded devices handle this with QT?
      I know there are other libraries like Ramtex, ucGUi and so on, but QT should be able to handle this also right?

    Please if you have any advise or help I would really appreciate it.

    Many Thanks


  • Lifetime Qt Champion


    1. If you use something like a QListView in IconMode you can navigate like with a standard keyboard (provided that your custom 5 button system is seen as a keyboard by your Raspberry Pi)

    2. A virtual keyboard would be required here, you can either do it phone style where you have the letter on the keypad or use a full virtual keyboard.

    3. Do you mean a plugin to e.g. map your 5 button thingy ?

  • Thanks.

    1. Sounds like a good navigation helper.

    2. Isnt it possible without such a keyboard? like gettin a input field if it go focus than get actual "cursor" position and just get the char and increase descrese it and on click right or left move the focus of the string?
      Is this ugly or sounds like a good plan? Since a virtual keyboard would require moving in x and y cordinates and not tap based. Or is it possible to use QT to move the focus in this x y way ? I just found the next/PrevFocus function right now.

    3. Not really a plugin, but maybe someone has done such a project and could share his project, so that I can get into it.

    Many Thanks

  • Lifetime Qt Champion

    1. I was thinking "console video game" style where you often had a full keyboard and moved over to the right letter and push e.g. a to validate. However in your case an "old phone" (as in not smartphone) key pad might be better. But in the end its your screen size and target market that should help you decide. You can use an event filter or reimplement the corresponding methods in your widget to do special handling.

    2. There's still the question: how does your RPI see that extension ? Are they just five button and you have to handle them by hand ? Is it a keyboard ?

  • HI,

    1. Yes the target display has only 240x120 Dots Resolution and we only have these 5 Keys . No additional kayboard attached. Okay the Event filter thing could be helpful. Is it also available in QT to do a special event filter for Inputs, Comboxes? Otherwise I would need to get the focused Widget and get the regarding object somehow?

    2. We are not using a RPI, the RPI was just a look a like graphic ;). We are using a custom board which has only these 5 Buttons attached (similar to the image of the RPI). As far as I can see for now I think, we need to provide a own keyboard driver for these 5 buttons. But we wont have more buttons and no touch screen. So it is hard for me to handle it since I have worked with touch based devices only, until now.


  • Lifetime Qt Champion

    Since you're on 4.8, QWSKeyboardHandler might be of interest if you don't have a kernel driver that turns your five buttons into a system keyboard. If you map these buttons with up/down/left/right and enter you have the basics or your navigation and would need to essential work on moving the focus from one widget to the other.

  • I got it working today with the QWS KEYPAD define switch and setNavigationMode .

    Now i can navigate as I thought, but now I have the next questions:

    • How can I handle dynamic ListWidget menus, which must be possible to navigate forward and backward?
      My approach was QVector containing the QWidgetListItem*, but I will always have the ui->ListWidget_Submenu for all submenus, so I cannot clearly decide which action should be done for which List Item.

    Also it is not really clear at the moment how to handle the menu. In worst case I need to have a menu map in the background which always gets updated if the list gets changed and the user wants to move back. Hmmmm.

    Is there a nicer way to handle such List Menus with Submenus? I do not want to create a new ListWidget for each Submenu ;(.

    -MENU Entry -> emit some function
    -MENU 2 -> SubMenuItems ->SubMenuItems ->Items->Dialogs etc.
    -MENU 3 -> SubMenuItems ->SubMenuItems ->Items->Dialogs etc.

    Is it possible to set unique identifiers for each ListItem and also get it back during the Slot call? clicked etc.?
    So it would be possible to say what action should be done.

    • Another issue I am focusing right now is that comboboxes can be selected with end with Key_Select they drop down, but it is not possbile to select an item in the drop down list. The focus moves forward to the next element. So how can I select such combobox item? Special EventFilter , but for what exactly?


  • Lifetime Qt Champion

    I don't know whether you saw this but I think you should take a look at the QtGamepad module. It might simplify things for your use case

Log in to reply