Important: Please read the Qt Code of Conduct -

How to stop QSlider being affected by mousewheel unless selected?

  • I've created a control that contains a QSlider in it. This control is in turn embedded in a scroll panel. When the user mouses over the scroll panel and scrolls the mouse wheel, my entire control within the panel scrolls - until the slider moves under the mouse cursor at which point the component suddenly switches from scrolling the component to moving the slider bar.

    Is there any way to avoid this? I would like to either disable mouse wheel scrolling entirely for my slider or have it so that the slider will only scroll if it is selected.

  • @kitfox you may want to reimplement the wheelEvent(QWheelEvent *e) method in your QSlider

  • Lifetime Qt Champion


    You could use an event filter that you'd disable when your widget has the focus.

Log in to reply