THRESHE
26th May 2008, 16:29
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:
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 ?
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:
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 ?