You can do this with the event filter on the widgets in question. See QObject :: eventFilter () . Your implementation might look something like this:
bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (ui->pushButton) { if (event->type() == QEvent::MouseButtonRelease) { qDebug() << "mouse button"; return true; } else { return false; } } else {
This will work even if the button is disabled.
source share