// Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TYPEWITHSPECIALPROPERTIES_H #define TYPEWITHSPECIALPROPERTIES_H #include #include #include class TypeWithSpecialProperties : public QObject { Q_OBJECT QML_ELEMENT Q_PROPERTY(int x MEMBER m_x) Q_PROPERTY(QString y MEMBER m_y) Q_PROPERTY(double z BINDABLE bindableZ READ default WRITE default) // for alias attributes: Q_PROPERTY(QString xx READ xx CONSTANT) Q_PROPERTY(QString xy READ xy WRITE setXy RESET resetXy NOTIFY xyChanged) QProperty m_x; QProperty m_z; QProperty m_xx; QProperty m_xy; public: QProperty m_y; TypeWithSpecialProperties(QObject *parent = nullptr) : QObject(parent) { } QBindable bindableZ() { return QBindable(&m_z); } QString xx() const { return m_xx; } QString xy() const { return m_xy; } void setXy(const QString &xy) { m_xy = xy; Q_EMIT xyChanged(); } void resetXy() { m_xy = QStringLiteral("reset"); } Q_SIGNALS: void xyChanged(); }; #endif // TYPEWITHSPECIALPROPERTIES_H