superqt icon indicating copy to clipboard operation
superqt copied to clipboard

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

Open sfhbarnett opened this issue 3 years ago • 3 comments

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):

  • macOS 12.1
  • PyQt5 5.15.6
  • superqt 0.3.1
  • Python 3.9.7

sfhbarnett avatar Mar 21 '22 09:03 sfhbarnett

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 avatar Mar 21 '22 13:03 tlambert03

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

tlambert03 avatar Mar 22 '22 14:03 tlambert03

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

sfhbarnett avatar Mar 22 '22 20:03 sfhbarnett

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

tlambert03 avatar Oct 02 '22 13:10 tlambert03