subclass QSlider to go to a value on one click
Hi everybody
I'm writing a video player right now and I need a slider like in media player classic. I've was frustrated when I found that Qt does not have a way to go to the certain value on click. So I've tried to do it by subclassing QSlider like this:
Code:
void QProgressSlider
::mouseReleaseEvent(QMouseEvent* event
) {
event->ignore();
double k = ((double)event->x())/((double)width());
int a = k*(maximum());
setValue(a);
}
This is close but some times the handle misses the cursor. I've also tried to use
int QSliderPrivate:: pixelPosToRangeValue(int pos) function but the results are the same.
Any suggestions ?
Re: subclass QSlider to go to a value on one click
One can do it easily with good old [WIKI]proxy style[/WIKI]:
Code:
{
if (hint == SH_Slider_AbsoluteSetButtons)
return Qt::LeftButton; // or "Qt::LeftButton | Qt::RightButton"
return ProxyStyle::styleHint(hint, option, widget, returnData);
}
Re: subclass QSlider to go to a value on one click
Re: subclass QSlider to go to a value on one click
READ through the link I gave.