From b6e713c306a5c8d46613cbde2db23df480b5ad5c Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Tue, 19 Jan 2021 09:45:56 +0800 Subject: [PATCH] bug: AlignCenter should have been AlignHCenter from the Qt documentation, - "AlignCenter = AlignVCenter | AlignHCenter" - "You can use at most one horizontal and one vertical flag at a time. Qt::AlignCenter counts as both horizontal and vertical" - "Conflicting combinations of flags have undefined meanings" for AxisItem.py, from the code structure, it would appear that the intent was to use AlignHCenter. for ROI.py, AlignCenter == AlignCenter | AlignVCenter --- pyqtgraph/graphicsItems/AxisItem.py | 4 ++-- pyqtgraph/graphicsItems/ROI.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py index ed36a676..4c0f0de2 100644 --- a/pyqtgraph/graphicsItems/AxisItem.py +++ b/pyqtgraph/graphicsItems/AxisItem.py @@ -1110,10 +1110,10 @@ class AxisItem(GraphicsWidget): textFlags = QtCore.Qt.TextDontClip|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter rect = QtCore.QRectF(tickStop+offset, x-(height/2), width, height) elif self.orientation == 'top': - textFlags = QtCore.Qt.TextDontClip|QtCore.Qt.AlignCenter|QtCore.Qt.AlignBottom + textFlags = QtCore.Qt.TextDontClip|QtCore.Qt.AlignHCenter|QtCore.Qt.AlignBottom rect = QtCore.QRectF(x-width/2., tickStop-offset-height, width, height) elif self.orientation == 'bottom': - textFlags = QtCore.Qt.TextDontClip|QtCore.Qt.AlignCenter|QtCore.Qt.AlignTop + textFlags = QtCore.Qt.TextDontClip|QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop rect = QtCore.QRectF(x-width/2., tickStop+offset, width, height) #p.setPen(self.pen()) diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py index 4f23ccd1..a48e970e 100644 --- a/pyqtgraph/graphicsItems/ROI.py +++ b/pyqtgraph/graphicsItems/ROI.py @@ -2330,7 +2330,7 @@ class RulerROI(LineSegmentROI): p.resetTransform() txt = fn.siFormat(length, suffix='m') + '\n%0.1f deg' % angle - p.drawText(QtCore.QRectF(pos.x()-50, pos.y()-50, 100, 100), QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter, txt) + p.drawText(QtCore.QRectF(pos.x()-50, pos.y()-50, 100, 100), QtCore.Qt.AlignCenter, txt) def boundingRect(self): r = LineSegmentROI.boundingRect(self)