O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Triggering usecases::AddGroceryItem::run

The use case add grocery item should be triggered when the Add item button is pressed or clicked. We thus need a signal and a signal handler for a button press event. By looking at the documentation for the Qt Quick Controls 2 Button (https://doc.qt.io/qt-5.9/qml-qtquick-controls2-button.html), we discover that it provides a clicked  signal, with the respective  onClicked  signal handler.

But how can we get hold of the button element in Page1? The Add item  button is a child of Page1Form, and as such it cannot be referenced directly from outside Page1Form; that is, the button is not part of Page1Form's API. For cases like this, QML provides  property aliases (http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#property-aliases ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required