Since QLabel is a subclass of QWidget, you can handle mouse click events in QLabel :: mousePressEvent
virtual void mousePressEvent ( QMouseEvent * ev )
But in QMainWindow you can use childAt to get child widgets in x, y
QWidget * QWidget::childAt ( int x, int y ) const QLabel* label= static_cast<QLabel*>(mainWindow->childAt(x,y));
More details: http://doc.qt.io/qt-5/qwidget.html#childAt
Ahmad Mushtaq
source share