Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyqt get pixel position and value when mouse click on the image

I would like to know how i can select a pixel with a mouse click in an image (QImge) and get pixel position and value.

Thanks

like image 515
polyBrain Avatar asked Aug 17 '10 16:08

polyBrain


1 Answers

self.image = QLabel()
self.image.setPixmap(QPixmap("C:\\myImg.jpg"))
self.image.setObjectName("image")
self.image.mousePressEvent = self.getPos

def getPos(self , event):
    x = event.pos().x()
    y = event.pos().y() 
like image 51
Jay Avatar answered Nov 15 '22 22:11

Jay