if(event->type()==QEvent::Resize)
{
QStyleOptionSlider opt;
opt.initFrom(_ui->slider);
QRect handle = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, _ui->slider);
QRect area=_ui->plot->axisRect()->rect();
QRect graphGeometry=_ui->plot->geometry();
QRect sliderGeometry=_ui->slider->geometry();
int leftVal=area.left();
if(!_playBackXValues.isEmpty())
leftVal=_ui->plot->xAxis->coordToPixel(_playBackXValues.first());
QRect newGeometry(area.left()+graphGeometry.left()-handle.width()/2.0,sliderGeometry.y(),area.width()+handle.width(),sliderGeometry.height());
if(leftVal>0)
newGeometry=newGeometry.adjusted(leftVal-area.left(),0,-leftVal+area.left(),0);
_ui->slider->setGeometry(newGeometry);
return true;
}
return QObject::eventFilter(watched, event);
basically my code is creating a slider that is the exact width of the graph so that it can be slid to line up with a line that we are placing in the data.