Skip to Content
C++ Reactive Programming
book

C++ Reactive Programming

by Praseed Pai, Peter Abraham
June 2018
Intermediate to advanced
348 pages
8h 45m
English
Packt Publishing
Content preview from C++ Reactive Programming

Event handlers

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Functional Programming in C++

Functional Programming in C++

Ivan Cukic

Publisher Resources

ISBN: 9781788629775Supplemental Content