How it works…

QML is designed to be easily extensible through C++ code. The classes in the Qt QML module enable QML objects to be loaded and manipulated from C++.

Only classes that are inherited from the QObject base class can be integrated with QML, as it is part of the Qt ecosystem. Once the class has been registered with the QML engine, we get the root item from the QML engine and use it to find the objects we want to manipulate. After that, use the setProperty() function to change any of the properties belong to the widget.

Notice that the Q_INVOKABLE macro is required in front of the function that you intend to call in QML. Without it, Qt will not expose the function to Qt Quick and you will not be able to call it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset