Skip to content

Commit

Permalink
Merge pull request #3989 from t20100/fix-pyqt6
Browse files Browse the repository at this point in the history
silx.gui: Fixed `QMouseEvent.globalPos()` not available with PyQt6
  • Loading branch information
vasole authored Dec 8, 2023
2 parents 5a0ee15 + f67ed75 commit fcb2711
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/silx/gui/plot/ColorBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 5 additions & 1 deletion src/silx/gui/plot/LegendSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fcb2711

Please sign in to comment.