Qt Android: virtual keyboard keeps going uppercase when I type QLineEdit

When I enter QLineEdit, the virtual keyboard starts with an uppercase. Even if I set it to lowercase, it will return to upper case as soon as I type one character. That is, every time I type a character, the reset keyboard is again delayed.

This happens even in a newly created project (I just put in a line edit and started it).

I found a forum topic about the same issue - https://groups.google.com/forum/#!topic/android-qt/QMFZmkACAIA .

I am using Qt / C ++ (not QML).

Edit: Just test it on a new QML project, the error is there too. I also found a thread posted about this for QML - https://groups.google.com/forum/#!msg/android-qt/BzGDGoLNtYc/TdtOX9MW3vIJ .

Edit 2: I tested with inputMethodHints (), and the only thing that had an effect was ImhNoAutoUppercase. But then it still started with a capital letter char, and when you press the back button (to delete the last character), the keyboard switches back to upper case, even if you typed a few letters. After the first letter, it switches to lowercase, and if you do not press the "Back" button, it works basically in order.

+7
c ++ android qt
source share
1 answer

Edit: A few good workarounds are installing ImhNoAutoUppercase , the first letter is still capitalized, but at least the next letters you enter will have lowercase letters.

Original answer: On Android, this will be set using inputType in the EditText in the xml of the layout file for Activity / Fragment (the screen / page you are looking at). Can you access and edit the layout file directly for Android?

Using setInputMask () to control input type? It is possible that forcing a lowercase letter (or switching case conversion) makes it possible to use upper or lower case. I assume that the Android layout XML file has inputType = "textCapSentences" or something similar ( https://developer.android.com/training/keyboard-input/style.html ).

UPDATE: You mention that the problem is fixed in 5.4. This is like a commit that will fix it. I would suggest just implementing the fixes shown here. https://qt.gitorious.org/qt/qtbase/commit/2b3f293d892c5268bd2a07ed17fa9fc5adacbd76

You mentioned that you can edit the source code of Qt. I think the error may be in this part src / org / qtproject / qt5 / android / QtActivityDelegate.java

  if ((inputHints & ImhUppercaseOnly) != 0) { initialCapsMode |= android.text.TextUtils.CAP_MODE_CHARACTERS; inputType |= android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; } else if ((inputHints & ImhLowercaseOnly) == 0 && (inputHints & ImhNoAutoUppercase) == 0) { initialCapsMode |= android.text.TextUtils.CAP_MODE_SENTENCES; inputType |= android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; } 

Must be changed to:

  if ((inputHints & ImhUppercaseOnly) != 0) { initialCapsMode |= android.text.TextUtils.CAP_MODE_CHARACTERS; inputType |= android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; } else if ((inputHints & ImhLowercaseOnly) == 0 && (inputHints & ImhNoAutoUppercase) == 0) { //initialCapsMode |= android.text.TextUtils.CAP_MODE_SENTENCES; // not sure what to set here - could try 0 or null if commenting out line doesn't work inputType |= android.text.InputType.TYPE_CLASS_TEXT; } 

If this does not fix, I suggest looking for the source code for android.text.InputType.TYPE_TEXT_FLAG_CAP or android.text.TextUtils.CAP_MODE and replacing them with trial and error.

+1
source share

All Articles