dexter dexterovich
dexter dexterovich

Reputation: 61

PyQT - How to get coordinates of an image selection

I have to get the coordinates of a section of an image in PyQT. At first I need a widget that can show an image (png or jpeg) but I don't know which can do this. And then I must select a portion of this image with a rectangle and get the top-left and bottom-right coordinates of the rectangle. Thank you

Upvotes: 1

Views: 2144

Answers (1)

alexisdm
alexisdm

Reputation: 29896

You can display images:

  1. with a QLabel and its method QLabel.setPixmap, OR
  2. with a QGraphicsScene/QGraphicsView, OR
  3. in a QWidget by redefining the paintEvent method and using e.g. QPainter.drawPixmap.

Once the image is displayed you can use a QRubberBand (example) to allow and display the selection.

Upvotes: 3

Related Questions