class MyProperty : public QObject{ Q_OBJECT Q_PROPERTY(bool show READ show WRITE setShow)public: MyProperty(QObject *parent = 0); bool show() const;public slots: void setShow(bool on);signals: void showChanged(bool on);}
C++ (Qt)class MyProperty : public QObject{ Q_OBJECT Q_PROPERTY(bool show READ show WRITE setShow)public: MyProperty(QObject *parent = 0); bool show() const; public slots: void setShow(bool on); private: bool show;signals: void showChanged(bool on);}
class MyProperty : public QObject{ Q_OBJECT Q_PROPERTY(bool show READ show WRITE setShow)public: MyProperty(QObject *parent = 0); bool show() const { return false; } public slots: void setShow(bool on) { emit showChanged(on); }signals: void showChanged(bool on);};
class Cloud : public QObject, public QGraphicsItem{ Q_OBJECT Q_INTERFACES(QGraphicsItem) Q_PROPERTY(QString Name READ name WRITE setName DESIGNABLE true USER true) public: Cloud(QGraphicsItem *parent = 0, QGraphicsScene *scene = 0); ~Cloud(); QString name() const {return m_name;} void setName(const QString& name); QRectF boundingRect() const; void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); QPainterPath shape() const;private: QString m_name;};...//применение Cloud *cloud = new Cloud(); cloud->Name="myName";