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 回答1: 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() 回答2: First you have to draw the image. You can do this my making a QLabel widget and call setPixmap . You need to convert your QImage to QPixmap before