Potential Qt5 bug on Android. Screen.Width * Screen.devicePixelRatio off by 1 pixel
-
Hi,
Me and my team have been noticing that on some Android devices with Qt5.15, there is a 1px white line on the short side of the screen (rotates when the device changes orientation). I've been looking like crazy to figure out where it was coming from and it seems like the only thing that makes it disappear is set
visible: false
on the main Window object (in our main.qml). Hiding any of the child views doesn't fix it.So I got curious. I added handlers in the main QML window for
onWidthChanged()
and I loggedScreen.width * Screen.devicePixelRatio
on a device that had this issue (Google Pixel 8 Pro). The output was 2991. Then in the MainActivity.java file, I did:DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int height = displayMetrics.heightPixels; int width = displayMetrics.widthPixels; Log.d("ANDROID_QT", "MainActivity.java: width: " + width);
and lo and behod, the output is 2992.
So Qt is shaving off 1 pixel somewhere and that is causing a 1 pixel white line. My questions are:
- Is this a known Qt5 bug?
- Did anyone else come across this?
- Is there a workaround?
- Would this be fixed if we migrated to Qt6?
-
Hi,
Me and my team have been noticing that on some Android devices with Qt5.15, there is a 1px white line on the short side of the screen (rotates when the device changes orientation). I've been looking like crazy to figure out where it was coming from and it seems like the only thing that makes it disappear is set
visible: false
on the main Window object (in our main.qml). Hiding any of the child views doesn't fix it.So I got curious. I added handlers in the main QML window for
onWidthChanged()
and I loggedScreen.width * Screen.devicePixelRatio
on a device that had this issue (Google Pixel 8 Pro). The output was 2991. Then in the MainActivity.java file, I did:DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int height = displayMetrics.heightPixels; int width = displayMetrics.widthPixels; Log.d("ANDROID_QT", "MainActivity.java: width: " + width);
and lo and behod, the output is 2992.
So Qt is shaving off 1 pixel somewhere and that is causing a 1 pixel white line. My questions are:
- Is this a known Qt5 bug?
- Did anyone else come across this?
- Is there a workaround?
- Would this be fixed if we migrated to Qt6?
Hi @Nihilish, it could be this bug: https://bugreports.qt.io/browse/QTBUG-87334 If that's the case, then the latest version (Qt 6.9.1) should be fixed
-
Hi @Nihilish, it could be this bug: https://bugreports.qt.io/browse/QTBUG-87334 If that's the case, then the latest version (Qt 6.9.1) should be fixed