Open Kwaskoff opened 4 years ago
Useful but will have to check what Qt widgets offer to implement this feature...
Qt itself doesn't provide an public API to convert a mouse position on an QSlider to a value (to which it would jump when left mouse button is clicked) But SMPlayer has such tooltip support on its time slider
https://app.assembla.com/spaces/smplayer/subversion/source/HEAD/smplayer/trunk/src/timeslider.cpp
relevant code part:
bool TimeSlider::event(QEvent *event) {
if (event->type() == QEvent::ToolTip) {
QHelpEvent * help_event = static_cast<QHelpEvent *>(event);
//qDebug() << "TimeSlider::event: x:" << help_event->x() << "maximum:" << maximum() << "width:" << width() << "total_time:" << total_time;
QStyleOptionSlider opt;
initStyleOption(&opt);
const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
const QPoint center = sliderRect.center() - sliderRect.topLeft();
int value = pixelPosToRangeValue(help_event->x() - center.x());
int range = maximum() - minimum();
qreal time = value * total_time / range;
//qDebug() << "TimeSlider::event: value:" << value << "range:" << range << "time:" << time;
if (time >= 0 && time <= total_time) {
QToolTip::showText(help_event->globalPos(), Helper::formatTime(time), this);
} else {
QToolTip::hideText();
event->ignore();
}
return true;
}
return QWidget::event(event);
}
I need open an video at the goal time and when move mouse need touch every time for understand how much time