Since #9814, moving the mouse on a Qt4Agg window raises the exception
Traceback (most recent call last):
File "/home/antony/src/extern/matplotlib/lib/matplotlib/backends/backend_qt5.py", line 294, in enterEvent
x, y = self.mouseEventCoords(event.pos())
AttributeError: 'QEvent' object has no attribute 'pos'
(Qt5 instead uses a QEnterEvent here, which does have a pos()).
Bug fix for 2.2.x yes but not for 3.0. Since you have qt4 can you see which position attribute is passed to the event? If there is none then that does not make sense at all.
Qt4 is deprecated. Anyway Unless the event gives us position then a possible fix is to catch the error and pass None as coordinates. This will also be a bug where user complains why no positions are passed down.
Traceback (most recent call last):
File "matplotlib/backends/backend_qt.py", line 262, in enterEvent
AttributeError: 'QResizeEvent' object has no attribute 'pos'
Having a similar issue in version 3.5.0, using pyqt5.
@noonchen this is a new issue after a major refactor of the code. You can see the filename has changed.
Nevertheless I do not understand why the enterEvent is triggered if you are trying to do a resize.
There exist a resizeEvent on line 334.
Could you describe what you are trying? Please also attach a sample code. Eventually create a new bug report.
@lkjell Sorry for the late reply. I try to reproduce this issue but I failed to find the correct trigger, it happens once out of ~20 attempts maybe.
I am embedding the matplotlib canvas into the QTabWidget, and the canvas has enterEvent and resizeEvent callbacks connected for interaction. Based on my previous debugging experience, I noticed the resizeEvent would be triggered when I move the mouse in the figure, I'm not exactly sure why it happens, but I'm guessing it's because I used figure.canvas.restore_region and figure.canvas.copy_from_bbox in the callback functions.
@noonchen can you open a new issue? Is there any more of the traceback? If it is only happening occasionally I assume that this is some sort of race condition which are fun to trace down! We could just make that code even more forgiving, but it would be better if we could understand at least what the race is between.
Activity
lkjell commented on Jul 9, 2018
Won't fix for v3.0? https://github.com/pyside/PySide/issues/132 .
Not sure if this is a matplotlib bug as Qt 4.8 docs appears to be the same as Qt5.
http://doc.qt.io/archives/qt-4.8/qwidget.html#enterEvent
http://doc.qt.io/qt-5/qwidget.html#enterEvent
anntzer commented on Jul 10, 2018
It's clearly a (big) regression, so it should be fixed.
lkjell commented on Jul 10, 2018
Bug fix for 2.2.x yes but not for 3.0. Since you have qt4 can you see which position attribute is passed to the event? If there is none then that does not make sense at all.
anntzer commented on Jul 10, 2018
It's an object of class QEvent, which has no pos().
It would not be acceptable (IMO) to basically say "mpl3 does not support Qt4".
lkjell commented on Jul 10, 2018
Qt4 is deprecated. Anyway Unless the event gives us position then a possible fix is to catch the error and pass None as coordinates. This will also be a bug where user complains why no positions are passed down.
tacaswell commented on Jul 10, 2018
We still support Qt4 and there is about to be one more release of it. I agree with @anntzer , dropping Qt4 support for mpl3 is not an option.
The simplest fix is to just catch the exception and do x = y = None which matches the fall-back behavior in https://github.com/matplotlib/matplotlib/pull/9814/files
FIX: be forgiving about the event for enteEvent not having a pos
FIX: be forgiving about the event for enterEvent not having a pos
lkjell commented on Jul 11, 2018
@anntzer btw is there a problem with leaveEvent aswell?
anntzer commented on Jul 11, 2018
No, leaveEvent() doesn't have xy info (perhaps it should?).
noonchen commented on Dec 3, 2021
Having a similar issue in version 3.5.0, using pyqt5.
lkjell commented on Dec 3, 2021
@noonchen this is a new issue after a major refactor of the code. You can see the filename has changed.
Nevertheless I do not understand why the enterEvent is triggered if you are trying to do a resize.
There exist a resizeEvent on line 334.
Could you describe what you are trying? Please also attach a sample code. Eventually create a new bug report.
noonchen commented on Dec 5, 2021
@lkjell Sorry for the late reply. I try to reproduce this issue but I failed to find the correct trigger, it happens once out of ~20 attempts maybe.
I am embedding the matplotlib canvas into the QTabWidget, and the canvas has enterEvent and resizeEvent callbacks connected for interaction. Based on my previous debugging experience, I noticed the resizeEvent would be triggered when I move the mouse in the figure, I'm not exactly sure why it happens, but I'm guessing it's because I used figure.canvas.restore_region and figure.canvas.copy_from_bbox in the callback functions.
tacaswell commented on Dec 6, 2021
@noonchen can you open a new issue? Is there any more of the traceback? If it is only happening occasionally I assume that this is some sort of race condition which are fun to trace down! We could just make that code even more forgiving, but it would be better if we could understand at least what the race is between.