From 7a88546fe63e12b8ccd0b303a012ff89a97f3213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20P=C3=A9rez=20Alonso?= Date: Mon, 9 Dec 2024 14:47:29 +0100 Subject: [PATCH] Fix centering of inner circle in PhotoVideoControl The inner circle in the PhotoVideoControl widget was not always perfectly centered due to a bug in Qt's anchors.centerIn property (QTBUG-95224) which causes it to return integer positions instead of subpixel values. Implemented a workaround by manually calculating the center position, ensuring exact centering regardless of parent and child dimensions and DPI scaling. This fix should be reverted once QGC moves to Qt 6.8.1 or higher, where the underlying Qt bug has been resolved. Related Qt bug: https://bugreports.qt.io/browse/QTBUG-95224 Qt fix commit: https://github.com/qt/qtdeclarative/commit/fd23a222efe189607eebd5c6782ca73eafa7080c --- src/FlightMap/Widgets/PhotoVideoControl.qml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/FlightMap/Widgets/PhotoVideoControl.qml b/src/FlightMap/Widgets/PhotoVideoControl.qml index 22bc144f338..d039bc61377 100644 --- a/src/FlightMap/Widgets/PhotoVideoControl.qml +++ b/src/FlightMap/Widgets/PhotoVideoControl.qml @@ -165,7 +165,11 @@ Rectangle { border.width: 3 Rectangle { - anchors.centerIn: parent + // anchors.centerIn snaps to integer coordinates before + // Qt v6.8.1 (QTBUG-95224), so we need to calculate + // manually for exact subpixel centering + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 width: parent.width * (_isShootingInCurrentMode ? 0.5 : 0.75) height: width radius: _isShootingInCurrentMode ? 0 : width * 0.5