Results 1 to 3 of 3

Thread: QSlider: direct jump

  1. #1
    Join Date
    Apr 2009
    Posts
    32
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSlider: direct jump

    When I press the left mouse button on a QSlider, it only does a certain page-step instead of jumping directly to the point that the mouse cursor points at. Is there anyway, I can make it jump directly to the point? I believe this is the standard behavior found in all movie players.

    Mads

  2. #2
    Join Date
    Jul 2011
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QSlider: direct jump

    I think you should subclass QProxyStyle to change return value of QStyle::SH_Slider_AbsoluteSetButtons hint in styleHint method. Something like that:
    Qt Code:
    1. class SliderStyle: public QProxyStyle{
    2. public:
    3. virtual int styleHint ( StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0 ) const{
    4. if (hint == QStyle::SH_Slider_AbsoluteSetButtons){
    5. return Qt::LeftButton;
    6. }else{
    7. return QProxyStyle::styleHint(hint, option, widget, returnData);
    8. }
    9. }
    10. };
    To copy to clipboard, switch view to plain text mode 

    Then create new SliderStyle and set is as your QSlider style.

  3. #3
    Join Date
    Apr 2011
    Posts
    39
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSlider: direct jump

    you can write in mousepressed event to set the value of the QSlider to the selected value,
    using checking the widget==QSlider in eventfilter ....

Similar Threads

  1. Qt + WINAPI + direct painting
    By JovianGhost in forum Qt Programming
    Replies: 8
    Last Post: 26th March 2010, 05:10
  2. Replies: 0
    Last Post: 22nd March 2010, 18:00
  3. Qt and hardware direct rendering on Linux
    By Vogel Ubrhar in forum Qt Programming
    Replies: 0
    Last Post: 22nd March 2010, 08:58
  4. Progress jump using QNetworkReply and SSL
    By danc81 in forum Qt Programming
    Replies: 4
    Last Post: 5th November 2009, 19:20
  5. How to use Signal through direct connection
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2007, 07:07

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.