June 2018
Intermediate to advanced
348 pages
8h 45m
English
Generally, events are rendered by calling associated virtual functions. The virtual function is responsible for responding as intended. If custom virtual function implementations do not perform all that is necessary, we may need to call the base class's implementations.
For example, the following example handles the left mouse button clicks on a custom label widget, while passing all other button clicks to the base QLabel class:
void my_QLabel::mouseMoveEvent(QMouseEvent *evt){ if (event->button() == Qt::LeftButton) { // handle left mouse button here qDebug() <<" X: " << evt->x() << "t Y: " << evt->y() << "n"; } else { // pass on other buttons to base class QLabel::mouseMoveEvent(event); }}
If we want to replace base class ...