pyapp-kit / superqt

Missing widgets and components for Qt-python
https://pyapp-kit.github.io/superqt/
BSD 3-Clause "New" or "Revised" License
210 stars 38 forks source link

qtrangeslider doesn't respond to drag properly on macOS 12 with Qt5.15 #74

Closed sfhbarnett closed 2 years ago

sfhbarnett commented 2 years ago

Describe the bug Qtrangeslider is not behaving properly. Dragging one of the handles causes the other handle to disappear (It looks like the slider thinks I have grabbed the top slider when I grab the bottom one). I've attached a video of the behaviour.

To Reproduce Steps to reproduce the behavior: The code below can reproduce the behaviour on my computer

    import sys
    from PyQt5 import QtCore, QtWidgets
    from superqt import QRangeSlider

    class MainWindow(QtWidgets.QMainWindow):

        def __init__(self, *args, **kwargs):
            super(MainWindow, self).__init__(*args, **kwargs)

            vlayout2 = QtWidgets.QHBoxLayout()
            self.qtr = QRangeSlider(QtCore.Qt.Orientation.Vertical)
            vlayout2.addWidget(self.qtr)
            widget = QtWidgets.QWidget()
            widget.setLayout(vlayout2)
            self.setCentralWidget(widget)

    def main():
        if not QtWidgets.QApplication.instance():
            app = QtWidgets.QApplication(sys.argv)
        else:
            app = QtWidgets.QApplication.instance()
        app.setQuitOnLastWindowClosed(True)
        main = MainWindow()
        main.show()
        sys.exit(app.exec_())

    if __name__ == '__main__':
        m = main()

Expected behavior Normal slider behaviour

Screenshots

https://user-images.githubusercontent.com/45679976/159230426-fcda91b9-2731-4798-8458-b26a73b0d196.mov

Desktop (please complete the following information):

tlambert03 commented 2 years ago

Thanks, I was able to reproduce this on PyQt5-5.15.6 and pyside2-5.15.2.1, but interestingly it works fine on PyQt6-Qt6-6.2.3 and pyside6-6.2.4 ... I went back and this has been there since at least v0.2.0, which is very surprising! I also happened to be on macOS 12.3 this time, so want to check some other machines to see if this depends on os version too.

thanks for the report!

tlambert03 commented 2 years ago

Was not able to reproduce on macOS 10.15 (catalina), so at this point, it appears to be specific to macos >= 11 and Qt < 6

sfhbarnett commented 2 years ago

Ok thanks for the updates! I don't have an issue moving to PyQt6 so that counts as a fix to me.

tlambert03 commented 2 years ago

doing some more research on this... it appears to be a bug with Qt itself on monterey: https://bugreports.qt.io/browse/QTBUG-98093

also described here: https://stackoverflow.com/questions/69890284/qslider-in-qt-misbehaves-in-new-macos-monterey-v12-0-1-any-workaround/69890285#69890285

it also looks like using a custom style sheet can solve it (for example, the styled sliders in the demo widget work fine)... so perhaps we can find a "cheat" solution similar to the SO post above