Luc4
19th June 2010, 15:32
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:
setValue(QStyle::sliderValueFromPosition(minimum() , maximum(), event->x(), width(), 0));
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:
void SliderProgressIndicator::mouseReleaseEvent(QMouseE vent* event) {
// Do whatever you do usually.
QSlider::mouseReleaseEvent(event);
// Do some other stuff...
}
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!
I searched the forums and I implemented this by adding in mousePressEvent the line:
setValue(QStyle::sliderValueFromPosition(minimum() , maximum(), event->x(), width(), 0));
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:
void SliderProgressIndicator::mouseReleaseEvent(QMouseE vent* event) {
// Do whatever you do usually.
QSlider::mouseReleaseEvent(event);
// Do some other stuff...
}
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!