Search code examples
c++qtcoordinatespixel

c++ How to take pixel coordinates from an image?


I have an image in C++ and I want to take the coordinates of a pixel (relatives to the image) clicking on it (with my picture available and open to click on it). I don't know how to define the signal and the slot required to do this. Thanks.


Solution

  • eventFilter(QObject *obj, QEvent *event){
    //blabla
    if (event->type() == QEvent::MouseButtonPress) {
    QMouseEvent* MouseEvGrip = (QMouseEvent*)event;
    Point2f clickePixel((float)MouseEvGrip->x(), (float)MouseEvGrip->y());
    //blabla
    }
    }