Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Successfully removing keys from the Qt virtual keyboard, sort of.

Successfully removing keys from the Qt virtual keyboard, sort of.

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.3k 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
    Circuits
    wrote on last edited by Circuits
    #1

    The following code allows me to remove the emoticons key and the language key from the keyboard:

            property var keyboardLayout: virtualKeyboard.keyboard.layout
            
            function disableKey(parent, objectText) {
                var obj = null
                if (parent === null)
                    return null
                var children = parent.children
                for (var i = 0; i < children.length; i++) {
                    obj = children[i]
                    if (obj.text === objectText && obj.toString().substring(0, 7) === "BaseKey") {
                        obj.enabled = false
                        obj.visible = false
                    }
                    obj = disableKey(obj, objectText)
                    if (obj)
                        break
                }
                return obj
            }
            
            function findChildByProperty(parent, propertyName, propertyValue, compareCb) {
                var obj = null
                if (parent === null)
                    return null
                var children = parent.children
                for (var i = 0; i < children.length; i++) {
                    obj = children[i]
                    if (obj.hasOwnProperty(propertyName)) {
                        if (compareCb !== null) {
                            if (compareCb(obj[propertyName], propertyValue))
                                break
                        } else if (obj[propertyName] === propertyValue) {
                            break
                        }
                    }
                    obj = findChildByProperty(obj, propertyName, propertyValue, compareCb)
                    if (obj)
                        break
                }
                return obj
            }
            
            onKeyboardLayoutChanged: {
                if(keyboardLayout !== ""){
                    var ChangeLanguageKey= findChildByProperty(virtualKeyboard.keyboard, "objectName", "changeLanguageKey", null)
                    if(ChangeLanguageKey){
                        ChangeLanguageKey.visible=false
                    }
                    if (keyboardLayout !== "") {
                        disableKey(virtualKeyboard.keyboard, ':-)')
                    }
                }
            }
    

    sort of... The problem is that both keys will return when I click the &123 key and then click the 1/2 key. I believe that is the shift key on the alternative keys page. Would it be possible to eliminate the language key and the emoticon key completely? Is there a better way to remove keys?

    raven-worxR 1 Reply Last reply
    0
    • C Circuits

      The following code allows me to remove the emoticons key and the language key from the keyboard:

              property var keyboardLayout: virtualKeyboard.keyboard.layout
              
              function disableKey(parent, objectText) {
                  var obj = null
                  if (parent === null)
                      return null
                  var children = parent.children
                  for (var i = 0; i < children.length; i++) {
                      obj = children[i]
                      if (obj.text === objectText && obj.toString().substring(0, 7) === "BaseKey") {
                          obj.enabled = false
                          obj.visible = false
                      }
                      obj = disableKey(obj, objectText)
                      if (obj)
                          break
                  }
                  return obj
              }
              
              function findChildByProperty(parent, propertyName, propertyValue, compareCb) {
                  var obj = null
                  if (parent === null)
                      return null
                  var children = parent.children
                  for (var i = 0; i < children.length; i++) {
                      obj = children[i]
                      if (obj.hasOwnProperty(propertyName)) {
                          if (compareCb !== null) {
                              if (compareCb(obj[propertyName], propertyValue))
                                  break
                          } else if (obj[propertyName] === propertyValue) {
                              break
                          }
                      }
                      obj = findChildByProperty(obj, propertyName, propertyValue, compareCb)
                      if (obj)
                          break
                  }
                  return obj
              }
              
              onKeyboardLayoutChanged: {
                  if(keyboardLayout !== ""){
                      var ChangeLanguageKey= findChildByProperty(virtualKeyboard.keyboard, "objectName", "changeLanguageKey", null)
                      if(ChangeLanguageKey){
                          ChangeLanguageKey.visible=false
                      }
                      if (keyboardLayout !== "") {
                          disableKey(virtualKeyboard.keyboard, ':-)')
                      }
                  }
              }
      

      sort of... The problem is that both keys will return when I click the &123 key and then click the 1/2 key. I believe that is the shift key on the alternative keys page. Would it be possible to eliminate the language key and the emoticon key completely? Is there a better way to remove keys?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @circuits
      https://doc.qt.io/qt-5/technical-guide.html#adding-custom-layouts

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Circuits
        wrote on last edited by
        #3

        @raven-worx Yes I have read that before. It seems to suggest that I would need to import all 43 layouts (if I want each language) and customize them each individually, is that correct?

        raven-worxR 1 Reply Last reply
        0
        • C Circuits

          @raven-worx Yes I have read that before. It seems to suggest that I would need to import all 43 layouts (if I want each language) and customize them each individually, is that correct?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @circuits
          yes, i am not aware of another way to achieve this

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1

          • Login

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