for any one who reads this i did it using QEventFilter.
this topic was helpful: http://www.qtcentre.org/threads/6272...cking-on-image

this is the code i use:
in header file:
Qt Code:
  1. bool eventFilter(QObject *o, QEvent *e);
To copy to clipboard, switch view to plain text mode 

in .cpp

Qt Code:
  1. //filter mouse tracking to the selection area only
  2. bool MainWindow::eventFilter(QObject *o, QEvent *e){
  3. if(o!= lblScrollImage) return false;
  4. if(e->type()==QEvent::MouseMove){
  5. QMouseEvent *mev = static_cast<QMouseEvent*>(e);
  6. QVariant x(mev->pos().x());
  7. QVariant y(mev->pos().y());
  8. ui->lblX->setText(x.toString());
  9. ui->lblY->setText(y.toString());
  10. //polyPoints << QPoint(x.toInt(), y.toInt());
  11. }
  12. else if (e->type()==QEvent::MouseButtonPress)
  13. {
  14. QMouseEvent *mev = static_cast<QMouseEvent*>(e);
  15. QVariant x(mev->pos().x());
  16. QVariant y(mev->pos().y());
  17. ui->lblX->setText(x.toString());
  18. ui->lblY->setText(y.toString());
  19. ui->lineEditX->setText(x.toString());
  20. ui->lineEditY->setText(y.toString());
  21. polyPoints << QPoint(x.toInt(), y.toInt());
  22. }
  23. return false;
  24. }
To copy to clipboard, switch view to plain text mode 


regards,
ahmed