Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Read the qtvirtualkeyboard current locale
Forum Updated to NodeBB v4.3 + New Features

Read the qtvirtualkeyboard current locale

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 547 Views
  • 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.
  • C Offline
    C Offline
    ChrisLe
    wrote on last edited by ChrisLe
    #1

    Hello

    I'm using qt5 virtualkeyboard with qtkioskbrowser and Yocto, branch dunfell.
    I need to persistently store the virtualkeyboard language / locale

    At start I do
    VirtualKeyboardSettings.locale = ls.getLocale();
    "ls.getLocale()" reads the locale from disk, e.g. "en_GB". When I open the virtualkeyboard, the locale is properly set.

    I also set
    Qt.inputMethod.localeChanged.connect(languageUpdated);
    which calls "languageUpdated" when I switch the virtualkeyboard locale.
    "languageUpdated" is called as expected but I don't know how to get the current locale.
    If I print "VirtualKeyboardSettings.locale", I see the locale I set at startup but not the one I switched to.

    function languageUpdated()
    {
    console.log(VirtualKeyboardSettings.locale);
    }
    Which attribute does return the current virtualkeyboard locale?

    I also found that "VirtualKeyboardSettings.availableLocales" is emtpy although I set
    "PACKAGECONFIG_pn-qtvirtualkeyboard = "lang-de_DE lang-es_ES lang-en_GB lang-ja_JP qtquickcompiler"

    I tried to set the languages manually
    VirtualKeyboardSettings.activeLocales = ["de_DE", "es_ES, "en_GB "ja_JP"]
    but this did not help.

    Help appreciated, Chris

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lemons
      wrote on last edited by
      #2

      set virtual keyboard language:

      Component.onCompleted: {
          VirtualKeyboardSettings.locale = "en_UK"
      }
      

      detect new locale when changing the keyboard language:

      Connections {
          target: InputContext
          onLocaleChanged: {
              console.debug("new locale:", InputContext.locale)
          }
      }
      

      limit the language selection list of the keyboard language button:

      Component.onCompleted: {
          VirtualKeyboardSettings.activeLocales = ["de_DE", "es_ES", "en_UK"]
      }
      
      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