Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dragging the bar on range sliders causes a crash with PyQt6 #107

Closed
sfhbarnett opened this issue Aug 4, 2022 · 3 comments
Closed

Dragging the bar on range sliders causes a crash with PyQt6 #107

sfhbarnett opened this issue Aug 4, 2022 · 3 comments

Comments

@sfhbarnett
Copy link
Contributor

Describe the bug
Dragging the bar (as opposed to the handles at the end) causes a crash with PyQt6 (and not PyQt5) with the following message:

  File "/Users/sbarnett/opt/anaconda3/envs/PyV2/lib/python3.9/site-packages/superqt/sliders/_generic_range_slider.py", line 149, in mouseMoveEvent
    delta = self._clickOffset - self._pixelPosToRangeValue(self._pick(ev.pos()))
AttributeError: 'QMouseEvent' object has no attribute 'pos'

Seemingly this is the result of a change in the Qt API https://stackoverflow.com/questions/67496362/qmouseevent-object-has-no-attribute-pos

A fix is to change ev.pos() to ev.position() on line 149 in _generic_range_slider.py. I'd do this and make a pull request but this breaks backwards compatibility with PyQt5 and I don't know how to maintain that (or if there's a way).

To Reproduce
Run the labeled.py example script with PyQt6 and click and drag the bar of a slider

Expected behavior
Slider bar drags

Screenshots
Screenshots and GIFS are much appreciated when reporting visual bugs.

Desktop (please complete the following information):

  • Mac OS 12.4
  • PyQT 6
  • Python 3.10
@tlambert03
Copy link
Member

thanks!

A fix is to change ev.pos() to ev.position() on line 149 in _generic_range_slider.py. I'd do this and make a pull request but this breaks backwards compatibility with PyQt5 and I don't know how to maintain that (or if there's a way).

that would be great thanks!

you can make a small compatibility function ... something like:

def _event_position(event):
    return event.pos() if hasattr(event, 'pos') else event.position()

@sfhbarnett
Copy link
Contributor Author

Great thanks! I learned something new today

@Czaki
Copy link
Contributor

Czaki commented Aug 26, 2022

close?

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

No branches or pull requests

3 participants