Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to stop QSlider being affected by mousewheel unless selected?

How to stop QSlider being affected by mousewheel unless selected?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 3.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kitfox
    wrote on last edited by kitfox
    #1

    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.

    Pablo J. RoginaP 1 Reply Last reply
    0
    • K kitfox

      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.

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by Pablo J. Rogina
      #2

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

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved