FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

AttributeError: 'QEvent' object has no attribute 'pos' · Issue #11607 · matplotlib/matplotlib · GitHub

Repository navigation

AttributeError: 'QEvent' object has no attribute 'pos' #11607

Closed

Description

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()).

attn @lkjell

Activity

  1. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Jul 9, 2018
  2. added this to the v3.0 milestone on Jul 9, 2018
  3. lkjell commented on Jul 9, 2018

    Contributor

    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

  4. anntzer commented on Jul 10, 2018

    ContributorAuthor

    It's clearly a (big) regression, so it should be fixed.

  5. lkjell commented on Jul 10, 2018

    Contributor

    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.

  6. anntzer commented on Jul 10, 2018

    ContributorAuthor

    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".

  7. lkjell commented on Jul 10, 2018

    Contributor

    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.

  8. tacaswell commented on Jul 10, 2018

    Member

    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

  9. added 2 commits that reference this issue on Jul 10, 2018
    7fd74ae
    5d3bb78
  10. lkjell commented on Jul 11, 2018

    Contributor

    @anntzer btw is there a problem with leaveEvent aswell?

  11. anntzer commented on Jul 11, 2018

    ContributorAuthor

    No, leaveEvent() doesn't have xy info (perhaps it should?).

  12. noonchen commented on Dec 3, 2021

    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.

  13. lkjell commented on Dec 3, 2021

    Contributor

    @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.

  14. 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.

  15. tacaswell commented on Dec 6, 2021

    Member

    @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GUI: QtRelease criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL