Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-1856

Q_PROPERTY(QString name IS m_string)

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P3: Somewhat important
    • 5.1.0
    • None
    • Core: Object Model
    • None

    Description

      From qt4-preview-feedback:

      It would be useful to have a Q_PROPERTY extension that works on simple data
      fields by itself (kind of using implicit accessor methods) – e.g. it would
      save some typing to be able to replace

      class Something:public QObject {
      Q_OBJECT
      Q_PROPERTY(QString something READ something WRITE setSomething)
      public:
      const QString &something() const

      { return m_something; }

      void setSomething(const QString &whatever)

      { m_something=whatever; }

      QString m_something;
      };

      with

      class Something:public QObject {
      Q_OBJECT
      Q_PROPERTY(QString something IS m_something)
      public:
      QString m_something;
      };

      or even

      class Something:public QObject {
      Q_OBJECT
      public:
      Q_PROPERTY(QString something READABLE true WRITABLE true); //
      <--- "something" is declared as a QString member and is accessible as
      property "something"
      };

      I know that most of the time having a member variable exposed directly without
      an accessor function is a bad idea, but for a few things it actually makes
      sense.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ogoffart Olivier Goffart (Woboq GmbH)
            bhughes Bradley T. Hughes (closed Nokia Identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes