Search code examples
qtpyqtqt4pyqt4pyside

Reliable QWidget to QImage coordinate transformation?


Mouse click events include click coordinates that are relative to the QWidget window in which the click occurred.

Assuming that the widget is displaying an image (i.e. the QWidget contains a QLabel whose QPixmap was built from a QImage), how can the mouse click position be converted into the QImage coordinates?


Solution

  • Looks like the most convenient solution is to process mouse clicks at the QLabel level instead of the QWidget in which it is included. In this case no conversion is needed.