Skip to content

Commit

Permalink
Fix centering of inner circle in PhotoVideoControl
Browse files Browse the repository at this point in the history
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:
qt/qtdeclarative@fd23a22
  • Loading branch information
rubenp02 committed Dec 11, 2024
1 parent 0141494 commit 7a88546
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/FlightMap/Widgets/PhotoVideoControl.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7a88546

Please sign in to comment.