It should be simple but somehow it's not working as it should. I'm trying to catch with eventFilter mouse button press or release on QListWidget. ListWidget was prepared under UI. I've installed eventFilter like this
ui->listWidget->installEventFilter(this);
I've added in header under public:
bool eventFilter(QObject *obj, QEvent *event);
And created under MainWindow
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::KeyPress)
{
qDebug() << "Keyboard press";
} else if (event->type() == QEvent::MouseButtonRelease) {
qDebug() << "Mouse press L";
} else if(event->type() == QEvent::ContextMenu) {
qDebug() << "Mouse press R";
}
return QObject::eventFilter(obj, event);
}
I've checked in the docs and It says that every event is being passed to eventHandler before sending to given QWidget. And it's partially true. Because KeyPress and ContextMenu is working. Even if list widget was set to blocksingals(true).
The problem is that MouseButtonRelease / Press is not working. Something is blocking it and I don't know what or how to make it working. I have on_listWidget_clicked also but even getting rid of it it is still not working.
Please help. Thanks