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

Priorities with change notification

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 4.8.0
    • Core: Other
    • None

    Description

      Use case:
      Data driven applications do a lot things like updating a given control on the screen,
      and put back new values of a control into the data container. Currently this has to be done manually.

      Example:

       
      class Data : public QObject {
      Q_OBJECT
      Q_PROPERTY( QString text READ text WRITE setText )
      public:
      QString text() const { return _text; }
      void setText( const QString &text ) {
      if (text != _text) {
      _text = text;
      emit someSignal();
      }
      }
      private:
      QString _text;
      }
      

      Problem: the notification mechanism isn't defined. So people tend to create for each property a own signal,
      which causes problems with generic implementation of features.

      Feature Request:
      Automate the generation of fully functional properties with notification and extend the current property system. Extend the MOC to automatically generate code for this simple properties.

      Example solution:
      There is a base class for elements which are supporting change notification.
      This base class has a signal "propertyChanged( QString )" which is emitted for each property which changes.
      Creation of the properties has been simplified with some preprocessor macros.

      class Project : public dzui::DocumentElement
      {
      Q_OBJECT
      Q_PROPERTY( QString identifier READ identifier WRITE setIdentifier );
      Q_PROPERTY( QString name READ name WRITE setName );
      Q_PROPERTY( QString installationPath READ installationPath WRITE setInstallationPath );
      Q_PROPERTY( QString directory READ directory WRITE setDirectory );
      
      public:
      Project( QObject *parent = 0 );
      virtual ~Project();
      
      public:
      DZ_DECL_PROPERTY( QString, identifier, setIdentifier );
      DZ_DECL_PROPERTY( QString, name, setName );
      DZ_DECL_PROPERTY( QString, installationPath, setInstallationPath );
      DZ_DECL_PROPERTY( QString, directory, setDirectory );
      
      private:
      QString _identifier;
      QString _name;
      QString _installationPath;
      QString _directory;
      };
      

      The implementation of this class:

      Project::Project( QObject *parent )
      : DocumentElement( parent )
      {
      }
      Project::~Project()
      {
      }
      DZ_IMPL_PROPERTY( QString, Project, identifier, setIdentifier );
      DZ_IMPL_PROPERTY( QString, Project, name, setName );
      DZ_IMPL_PROPERTY( QString, Project, installationPath, setInstallationPath );
      DZ_IMPL_PROPERTY( QString, Project, directory, setDirectory );
      

      --> The class is a fully functional data container which sends signals on property changes.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            qtcomsupport Qt Support
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes