[Development] Qt mobile input context scrolling

Olivier Goffart olivier at woboq.com
Thu Mar 9 09:08:38 CET 2017


On Donnerstag, 9. März 2017 06:33:11 CET Vlad Seryakov wrote:
> Hello,
> I am trying to disable Qt auto-scrolling on mobile devices(iOS, Android)
> when focusing on an input field in QtQuick.
> 
> For iOS it was pretty simple and just for a proof of concept making
> QIOSInputContext::scrollableRootView to always to return 0 disabled the
> auto-scrolling so we can in our app deal with keyboard showing or hiding.
> We have our own complex UI and auto-scrolling makes it a bad user
> experience. Dealing with it turned out to be more work and never ending
> race condition.
> 
> So, it works very good now on iOS, my next step will be android and this is
> not that straightforward. Not familiar with Android internals, and after
> reading Android platform plugin and base java/jar sources i am still
> puzzled when the scrolling happens.
> 
> Does anybody can point me where to look? This will save time but i am going
> to dig into it anyway, so this is not a request.

In the manifest file, you can use the setting
   android:windowSoftInputMode="adjustResize"

https://developer.android.com/guide/topics/manifest/activity-element.html

Personally, I think this is a much better setting that the panning, I wonder 
if it should be made the default. Most non-qt android application i've seen 
used that.
(However, there was a bug with Qt 5.6 that caused a flickering, I don't know 
if it has been fixed since)

> The actual question is, if disabling will show it is possible, what would be
> the solution to make it available to developers? For complex apps, the
> auto-scroll does not make sense. I looked into QPlatformIntegration
> classes, the only generic method is to set QPlatformWindow flags. At the
> same time with this little switch i do not want to break binary
> compatibility or change a lot of base classes. Having it available in the
> C++ at least makes it flexible to use the auto-scroll or not.

I believe the resizing the window is the way to go. Then, there is still need 
to do some integration to make sure that if there is a Flickable on this view, 
the input control stays visible (i.e: the Flickable scrolls to the right 
position). I have done that in QML in an application's own controls. But I 
believe it should be the default in Qt.

(You may wonder what's the difference between having the window being 
scrolled, or the Flickable being scrolled. The latter allow the user to 
continue to interact with the application normally, while the former hides the 
top part (which might include a title bar for example) and makes it harder for 
the user to navigate to other fields)

-- 
Olivier

Woboq - Qt services and support - https://woboq.com - https://code.woboq.org







More information about the Development mailing list