Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Symbian (and others?): How to translate "Q" into "1". Mapping char keys into numbers
Forum Updated to NodeBB v4.3 + New Features

Symbian (and others?): How to translate "Q" into "1". Mapping char keys into numbers

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 4 Posters 3.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    artem.marchenko
    wrote on last edited by
    #1

    Hi there

    My mobile app needs digit input only (some sort of a calculator) and I wouldn't like to bother the users with the need to switch to the digit input.

    Is there some Qt way for converting the key code (raw scan code maybe?) into a digit that is on that key even if keyboard is not in a digit input mode right now.

    On US/UK Symbian keyboard, for example, digit "1" shares key with the letter "Q", so I want to get 1 whenever user presses this key regardless of the input mode.

    Best regards,
    Artem.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Robbin
      wrote on last edited by
      #2

      Well one solution might be to check if the user entered letter or number, after which check what the letter is and return the co-responding number. Put the letters in a map for example and check there

      @
      QMap<int,QChar> m;
      m.insert(1,'Q');
      @

      then use

      @
      int number = m.key('Q');
      @

      I don't think there is any better solution to that, at least nothing Qt specific.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        artem.marchenko
        wrote on last edited by
        #3

        That would work, Eus, if I knew all the possible keyboard layouts for all the languages out there.

        I'd like to have it a little more platform independent (or at least locale independent, for now it's fine if solution is Symbian-specific).

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kamalakshantv
          wrote on last edited by
          #4

          [quote author="artem.marchenko" date="1315150257"]That would work, Eus, if I knew all the possible keyboard layouts for all the languages out there.

          I'd like to have it a little more platform independent (or at least locale independent, for now it's fine if solution is Symbian-specific).[/quote]

          The best option is to set your editor to numeric mode on initialization itself. This way user won't have to change it.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            artem.marchenko
            wrote on last edited by
            #5

            QtK, problem is that I don't use any editors. 95% of app is QML with my own controls with controls similar to these onces + a couple of buttons http://store.ovi.com/content/135126

            I draw on-screen keyboard for touch devices myself. For devices that also has hardware keyboard I use Keys element to listen to keyboard events ( http://doc.qt.nokia.com/4.7-snapshot/qml-keys.html ).

            So I'd probably need to some system-wide way to switch input mode to digits (ok, app-wide, not system-wide). I am not sure if it is possible at all.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Robbin
              wrote on last edited by
              #6

              Hm.... Well you could always capture key events, not sure how that would work with QML, sorrry =/
              I guess that the keys numeric values would be the same on all platforms with few differences at most, so that's the other thing you could check.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                artem.marchenko
                wrote on last edited by
                #7

                I don't mind capturing keys on the c++ side and then signaling them to QML, I just don't know how to translate the Q key scan code to whatever number lives on the same key.

                Well, for latin alphabet letter-number mapping is quite stable for full QWERTY keyboards and non-QWERTYs are not common. For non-latin alphabets it won't probably work, however.

                1 Reply Last reply
                0
                • AlicemirrorA Offline
                  AlicemirrorA Offline
                  Alicemirror
                  wrote on last edited by
                  #8

                  In the documentation about key scancode management you can find a useful example on how to manage keypressed under QML documents.

                  Enrico Miglino (aka Alicemirror)
                  Balearic Dynamics
                  Islas Baleares, Ibiza (Spain)
                  www.balearicdynamics.com

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved