PDA

View Full Version : How to get coordinates on an image



mshemuni
7th September 2012, 22:28
I have a QLabel and I'm displaying an image on it.
I'll get coordinate when I clicked on Qlabel.
There is some stars on my picture and I most find those coordinates.
How can I do it?
I hold images paths on a QListWidget named listWidgetPhoto. And when I clicked on listWidgetPhoto displayImage() will work.



def displayImage(self):

imagePath=self.listWidgetPhoto.currentItem()
print(imagePath.text())
self.label.setPixmap(QtGui.QPixmap(_fromUtf8(image Path.text())))



My sys.version output:
2.7.3 (default, Aug 1 2012, 05:16:07)
[GCC 4.6.3]
My OS:
bq. Ubuntu
Release 12.04 (precise) 32-bit

wysota
8th September 2012, 05:55
You need to handle mousePress/mouseRelease events on your widget. This will give you access to the position where the press/release occured. Then you'll be able to match that against your stored list of coordinates.