спасибо, получилось
bool MyScreenShot::eventFilter(QObject *obj, QEvent *event)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
if (event->type()==QEvent::MouseButtonPress)
{
start_paint = true;
curX = startX = mouseEvent->pos().x();
curY = startY = mouseEvent->pos().y();
}
if (event->type()==QEvent::MouseButtonRelease && start_paint)
{
start_paint = false;
endX = mouseEvent->pos().x();
endY = mouseEvent->pos().y();
}
if (event->type()==QEvent::MouseMove && start_paint)
{
endX = mouseEvent->pos().x();
endY = mouseEvent->pos().y();
QPainter p1( &theImage );
p1.setPen(QPen(Qt::black, 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
p1.setBrush(Qt::yellow);
p1.drawLine(curX,curY,endX,endY);
p1.end();
update();
repaint();
curX = mouseEvent->pos().x();
curY = mouseEvent->pos().y();
}
return false;
}