Qt for Android Development Big Pit
Author: Qyvlik
Qt 5.5.1
Here's a more common Qt developed for Android's big pits.
Hope that the students do not make unnecessary struggles, skip these pits.
Input box
The first is the input box, and Qt's input is poorly performed on Android.
Unable to support Android native input method to access Qt input box. Is the Android Input method cannot copy, paste, cut the text in the Qt input box.
You cannot support using touch to select text in the Qt input box.
It should be noted that the position of the input box is at the bottom of the app, similar to IM's chat tool.
A. Assume Activity
that the app is set to android:windowSoftInputMode="adjustResize"
, when the IME pops up. The application interface will be scaled. This time. The application interface will blink.
B. Assuming that the application is Activity
set to android:windowSoftInputMode="adjustPan"
, the head of the application interface will be top out of the screen.
In order to fix the issue of appeal, the following steps are as usual
A. Set the app Activity
settings first android:windowSoftInputMode="adjustPan"
, so. When the input method is ejected, it does not blink because of the interface zoom.
B. Get to Android Input method height.
C. Change the input box so that it is clicked to get the focus before the input input method ( Qt.inputMethod.show()
), because it is not the input box to get focus and pop-up. So the interface neither flashes nor moves upward relative to the screen. (Just TextField
put one on top MouseArea
)
D. After the Input method pops up, you will be able to get the keyboard height (assuming that you get the keyboard height on Android, you need to write some Java code).
E. After getting to the keyboard height, directly shift the input box (delay processing), then forceActiveFocus
force the focus.
The appeal solution also raises a question, and listens to my careful way.
A. First Qt.inputMethod.show()
, you can display the keyboard directly on Android. It is then displayed without directly scaling the interface (causing flicker) or by pushing the interface out of the screen.
B. Next, the input box is a special control. After the input box gets the focus of the virtual key. The IME on Android will remember the location of the control directly.
C. The next time you call directly Qt.inputMethod.show()
. Will find the position of the last input box to get the focus, according to this location, pop-up virtual key break and the interface top out of the screen. Then enter the box to get the keyboard height. Displacement.
In order to resolve the issue of appeal again. You also have to record the height of the keyboard on Android, and then depending on the height of the keyboard, first use Qt.inputMethod.show()
the pop-up keyboard, or the first shift input box.
Todo
Already has the solution of Gdpurjyfs/wellchat, demo video Android repair keyboard pop-up interface unfriendly issue repair final version demo. Of course, there are all kinds of problems and details to be done in these programs today. In fact it is hoped that the official fix keyboard pops up and the interface zooms out when the problem is flashing.
Qt Android Keyboard Issues
Camera
The camera on the Qt Android app. It is assumed QtMultimedia::Camera
that direct use may occur when there is no very good focus, and the performance of each model and the different version number system is inconsistent. Huawei's mobile phone support for Qt is poor and the problem will be slightly more.
Workaround:
Can directly through the call system of the camera software, detailed reference qtandroid detailed explanation (3): StartActivity real-combat Android camera function, detailed code a-week-to-develop-android-app-plan/demos/ Callnativecamera.
SplashScreen
Start screen, according to most qter reflect. When the Qt Android app starts. will display a no content. A black screen with title and app Icon. SplashScreen cannot be displayed directly in advance.
Local multimedia thumbnail image
network resources can be optimized and cached through existing C + + interfaces.
However, local multimedia thumbnails are supported. You need to build a good one yourself.
Web Support
QT Web support for mobile platforms should be to try to support by QtSurface
drawing native pages on, so QT Web support is very weak for mobile platforms. Then Qtwebengine is based on Google's Chromium, and Chromium now has the best support for VS compilers. Chromium's support for MinGW is largely non-essential.
Now QT is on the mobile device, using Qtwebview is to draw the native Web page on the Qtsurface as the solution of QT on the mobile side of the page.
Localization map
In QtQuick, the map plugin is supported. But the official just prefabricated a few foreign map plugins here. Baidu map can only go to encapsulate the plugin itself.
Discusses the use of QML qtlocation Plugin.
Qt for Android Development Big Pit