Results 1 to 2 of 2

Thread: Resetting a QSlider with double click

  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Resetting a QSlider with double click

    Hello!

    I have several QSliders scattered around on a quite complex GUI. All of them should be able to reset to 0 when double clicked. Unfortunately QSliders don't have a doubleClicked() signal that I connect to some slot. So what's the best way to implement this?

    Thanks
    Cruz

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Resetting a QSlider with double click

    QSlider is a QWidget, thus you can use QWidget::mouseDoubleClickEvent(). Simple subclass something like
    Qt Code:
    1. class MySlider : public QSlider
    2. {
    3. protected:
    4. void mouseDoubleClickEvent(QMouseEvent *event);
    5. }
    6.  
    7. MySlider::mouseDoubleClickEvent(QMouseEvent *event)
    8. {
    9. setValue(0);
    10. QSlider::mouseDoubleClickEvent(QMouseEvent *event);
    11. }
    To copy to clipboard, switch view to plain text mode 

    Or install an event filter.

  3. The following user says thank you to Lykurg for this useful post:

    Cruz (16th May 2011)

Similar Threads

  1. Replies: 6
    Last Post: 5th June 2009, 09:38
  2. Replies: 2
    Last Post: 11th January 2009, 23:24
  3. QGraphicsScene Click / Double Click
    By philentropist in forum Qt Programming
    Replies: 1
    Last Post: 9th February 2007, 04:32
  4. QSlider with double Heads..
    By moizahamedv in forum Qt Tools
    Replies: 5
    Last Post: 9th May 2006, 14:28
  5. Replies: 5
    Last Post: 12th January 2006, 15:40

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.