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. Disable Slider Click

Disable Slider Click

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 8.5k Views 1 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.
  • N Offline
    N Offline
    NDev
    wrote on last edited by
    #1

    I am looking for the way where I can customize the slider so that the only way to change the value is using the slider thumb. I want to get rid of the slider functionality, where slider value can be changed by just clicking on the slider bar.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      Subclass the QSlider and reimplement the mousePressEvent().

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • N Offline
        N Offline
        NDev
        wrote on last edited by
        #3

        thanks, but how do I track if the mouse is pressed on the thumb or it is on the slider bar?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          Note: I'm guessing based on how I would implement it.

          The thumb is probably a separate widget and has it's own mouse press events. I could be wrong though. Best course of action is to inspect the source of QSlider here and find out what exactly needs to be done. You could also try and find out by subclassing, reimplementing mousePressEvent to do nothing at all and see what happens. If that does what you need, you don't need to go into the source after all.

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • N Offline
            N Offline
            NDev
            wrote on last edited by
            #5

            I am not sure if thumb is a separate widget. Can i cast the sender object into QWidget and check its type?

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Franzk
              wrote on last edited by
              #6

              I might be wrong of course :).

              You can even check it's type without casting it to QWidget. It's a QObject after all.

              "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #7

                I think you have to subclass it and overwrite mouseEvents. Have a look at the Qt sources, afaik the slider thumb is only painted and no real object. look at the implementation of QSlider and see what they have done, then change yours according to it.

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0

                • Login

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