[Development] Qt mobile input context scrolling

Jason H jhihn at gmx.com
Thu Mar 9 17:52:26 CET 2017


> 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.
> 
> 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 do have some experience with this, yeah, I find it frustrating at times.
What I did was to represent the keyboard rect in my layout. But as you can see with the code below, I commented it out. I remember having experiences some Android/iOS differences. (As evidenced by the logic). It seems that this code was to handle the issue of the keyboard coming up over the listview. I also have have a comment in my android manifest: <!-- android:windowSoftInputMode="adjustResize" --> which seems to indicate that I removed that from the defaults, or I at least experimented with it. 

Anyhow, better control of the keyboard/window behavior would be greatly appreciated.

	Item {
		id: keyboardSpacer
		height: 0
		anchors{
			left: parent.left
			right: parent.right
			bottom: parent.bottom
		}
	}

	Connections {
		target: Qt.inputMethod
		onKeyboardRectangleChanged: {
			console.log("Qt.inputMethod.visible:", Qt.inputMethod.visible, Qt.inputMethod.keyboardRectangle.height 
                        //keyboardSpacer.height = (Qt.platform.os === "android") ? Qt.inputMethod.keyboardRectangle.height / Screen.devicePixelRatio: 0;
			listView.positionViewAtEnd()
		}
	}



More information about the Development mailing list