Advertisement
Guest User

Untitled

a guest
Jul 19th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <QtGui>
  2.  
  3. class Test : public QObject
  4. {
  5. Q_OBJECT
  6. Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
  7. private:
  8.     bool bReadOnly;
  9. public:
  10.     Test(QObject *pobj = 0)
  11.         : QObject(pobj), bReadOnly(false) {}
  12.     ~Test(){}
  13.     void setReadOnly(bool value)
  14.     {
  15.         bReadOnly = value;
  16.     }
  17.     bool isReadValue() const
  18.     {
  19.         return bReadOnly;
  20.     }
  21.     const char * getText() const
  22.     {
  23.         return bReadOnly ? "ReadOnly SET" : "ReadOnly NOT SET";
  24.     }
  25. };
  26.  
  27. int main (int argc, char *argv[])
  28. {
  29.     QApplication app(argc, argv);
  30.     Test tst;
  31.     tst.setProperty("readOnly", true);
  32.     QLabel text(tst.getText());
  33.     text.show();
  34.     return app.exec();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement