I am using Qt but have run into a problem.
I want to register when the mouse is pressed and released on a QTableWidget
. There are signals only for pressed, not released. Therefore I use mousePressEvent
and mouseReleaseEvent
instead.
MyWidget.h
protected:
void mousePressEvent(QMouseEvent * event);
void mouseReleaseEvent(QMouseEvent * event);
MyWidget.cpp
void MyWidget::mousePressEvent(QMouseEvent *event)
{
qDebug() << "Pressed";
}
void MyWidget::mouseReleaseEvent(QMouseEvent *event)
{
qDebug() << "Released";
}
It prints "Released" when the left, right or middle mouse button is released over the table. However, it prints "Pressed" only when the right or middle button is pressed.
What could be wrong? How can I register when the left button is pressed?
The cell widget probably consumes the mousePressEvent
on the left mouse button, so you (the parent widget) are not receiving it.