Reason not to use QPushButton::flat ist that QPushButton is atomic widget, not everything goes inside of it, and QFrame is just a frame, so basically surrounding the all widgets inside of it.
Just reimplement mousePressedEvent(QMouseEvent *me), mouseReleseEvent(QMouseEvent *me), and do like:
if (me
->buttons
() ^ me
->button
()) {QFrame::mousePressedEvent(me
);
return;
}
emit(myMousePressedSignal());
// here you shoud remember click event...
me->accept();
return;
}
QFrame::mousePressedEvent(me
);
}
if (me
->button
()) {QFrame::mouseReleasedEvent(me
);
return;
}
// here emit released and click signal if clicked... if not just call mouseReleasedEvent
// from the base class and forget about clicked, if clicked...
// Anyway each widget receives those events, not only QFrame....
}
void mousePressedEvent(QMouseEvent *me) {
if (me->buttons() ^ me->button()) {QFrame::mousePressedEvent(me); return;}
if (me->button() == QMouseEvent::LeftMouse) {
emit(myMousePressedSignal());
// here you shoud remember click event...
me->accept();
return;
}
QFrame::mousePressedEvent(me);
}
void mouseRelessedEvent(QMouseEvent *me) {
if (me->button()) {QFrame::mouseReleasedEvent(me); return;}
// here emit released and click signal if clicked... if not just call mouseReleasedEvent
// from the base class and forget about clicked, if clicked...
// Anyway each widget receives those events, not only QFrame....
}
To copy to clipboard, switch view to plain text mode
Bookmarks