Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Extending QML - Methods Example

Methods Support.

This example builds on:

The Methods Example has an additional method in the BirthdayParty class: invite(). invite() is declared with Q_INVOKABLE so that it can be called from QML.

    Q_INVOKABLE void invite(const QString &name);

In example.qml, the invite() method is called in the Component.onCompleted signal handler:

import QtQuick
import People

BirthdayParty {
    host: Person {
        name: "Bob Jones"
        shoeSize: 12
    guests: [
        Person { name: "Leo Hodges" },
        Person { name: "Jack Smith" },
        Person { name: "Anne Brown" }

    Component.onCompleted: invite("William Green")

Example project @ code.qt.io

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded