Results 1 to 4 of 4

Thread: QSlider

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question QSlider

    Is it possible to click anywhere on a QSlider bar and move the actual slider part to that point on the bar? Instead of dragging the slider to the desired location, just click on the desired location and move the slider to that spot? If this is possible what signal do I need to watch for or what else do I need to do? I cannot find anything that appears as if this idea will work. Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSlider

    To me, it sounds as if you will have to sub-class a slider and re-implement the mousePress or mouseRelease event handlers.

  3. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSlider

    But if I would re-implement those functions, then I would probably lose my capabilities to grab the slider and move it up and down the bar, right? Thanks again!

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QSlider

    Quote Originally Posted by ToddAtWSU
    But if I would re-implement those functions, then I would probably lose my capabilities to grab the slider and move it up and down the bar, right?
    You can, of course, call base class implementation if you want to. So you don't have to re-implement the whole event, you can just add some little tricks of your own and then let the base class handle the rest.

    I'd say, all you need to do is to override mouse press event; set the slider to the corresponding position, and then call base class implementation.

    And if you're wondering how to change the slider's value corresponding to the mouse position, check QSliderPrivate:ixelPosToRangeValue() in src/gui/widgets/qslider.cpp.
    J-P Nurmi

Similar Threads

  1. Problems customizing QSlider
    By Antrax in forum Qt Programming
    Replies: 13
    Last Post: 20th December 2011, 07:00
  2. how to number the ticks of QSlider
    By babu198649 in forum Newbie
    Replies: 4
    Last Post: 11th June 2008, 13:46
  3. QSlider problem
    By sincnarf in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2007, 01:07
  4. QSlider Update Problem
    By December in forum Qt Programming
    Replies: 4
    Last Post: 10th September 2006, 04:02
  5. Video and QSlider
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 1st May 2006, 19:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.