From f67ed75dddb4998f3dbe1a5689f660dff606be59 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Fri, 8 Dec 2023 16:50:16 +0100 Subject: [PATCH] Fix QMouseEvent.globalPos() deprecated --- src/silx/gui/plot/ColorBar.py | 6 +++++- src/silx/gui/plot/LegendSelector.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/silx/gui/plot/ColorBar.py b/src/silx/gui/plot/ColorBar.py index 9b50b5b9d8..2e61c8f91a 100644 --- a/src/silx/gui/plot/ColorBar.py +++ b/src/silx/gui/plot/ColorBar.py @@ -588,7 +588,11 @@ def paintEvent(self, event): def mouseMoveEvent(self, event): tooltip = str(self.getValueFromRelativePosition( self._getRelativePosition(qt.getMouseEventPosition(event)[1]))) - qt.QToolTip.showText(event.globalPos(), tooltip, self) + if qt.BINDING == "PyQt5": + position = event.globalPos() + else: # Qt6 + position = event.globalPosition().toPoint() + qt.QToolTip.showText(position, tooltip, self) super(_ColorScale, self).mouseMoveEvent(event) def _getRelativePosition(self, yPixel): diff --git a/src/silx/gui/plot/LegendSelector.py b/src/silx/gui/plot/LegendSelector.py index e70ab507bd..4c393acdc7 100755 --- a/src/silx/gui/plot/LegendSelector.py +++ b/src/silx/gui/plot/LegendSelector.py @@ -453,7 +453,11 @@ def editorEvent(self, event, model, option, modelIndex): # Mouse events are sent to editorEvent() # even if they don't start editing of the item. if event.button() == qt.Qt.RightButton and self.contextMenu: - self.contextMenu.exec(event.globalPos(), modelIndex) + if qt.BINDING == "PyQt5": + position = event.globalPos() + else: # Qt6 + position = event.globalPosition().toPoint() + self.contextMenu.exec(position, modelIndex) return True elif event.button() == qt.Qt.LeftButton: # Check if checkbox was clicked