Results 1 to 2 of 2

Thread: QSlider and sliderReleased() signal

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QSlider and sliderReleased() signal

    Hi everyone! I subclassed a QSlider to create one which reacts to mousePressEvent and mouseReleaseEvent. Seemed to work quite well till I added the capability for the user to change the slider position by just clicking the slider in some place.

    I searched the forums and I implemented this by adding in mousePressEvent the line:

    Qt Code:
    1. setValue(QStyle::sliderValueFromPosition(minimum(), maximum(), event->x(), width(), 0));
    To copy to clipboard, switch view to plain text mode 

    This seems to correctly place the handle of the slider, after that mouseReleaseEvent is called correctly, but it seems the signal mouseReleaseEvent is not. This is my mouseReleaseEvent method:

    Qt Code:
    1. void SliderProgressIndicator::mouseReleaseEvent(QMouseEvent* event) {
    2. // Do whatever you do usually.
    3. QSlider::mouseReleaseEvent(event);
    4.  
    5. // Do some other stuff...
    6. }
    To copy to clipboard, switch view to plain text mode 

    mouseReleaseEvent seems to be called (placed a breakpoint and it's ok), but the singal seems not to be sent. The signal is instead sent when I drag the handle. Any idea why?

    I could simply emit it manually, but in the case of the drag I would get the signal is emitted twice...

    Thanks!

  2. #2
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QSlider and sliderReleased() signal

    I solved by emitting a different signal. I don't know why the sliderReleased() signal is not sent, but the solution was quite simple.

Similar Threads

  1. Replies: 4
    Last Post: 4th March 2010, 12:44
  2. QSlider
    By mickey in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2009, 18:21
  3. Replies: 2
    Last Post: 6th July 2009, 13:53
  4. QSlider
    By merry in forum Qt Programming
    Replies: 22
    Last Post: 27th June 2007, 08:42
  5. QSlider
    By ToddAtWSU in forum Qt Programming
    Replies: 3
    Last Post: 10th May 2006, 17:41

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.