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

Support c++11/c++20 templates for QObjects

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 5.13.0 RC 3, 5.14.0 RC2, 5.15.0 RC2
    • Build tools: moc
    • None
    • All

    Description

      I would like to create templated QObjects. This would allow me to create a Property structure for example. Which is fully compatible with QML without writing getters and setters and signals for each property and binding it over a Q_PROPERTY macro. Which is prone to bugs and also limits the use of all c++ features.

      For example: I would like to have something like the following:

      template <std::equality_comparable T>
      class Property : QObject<Property<T>> {
      //Q_OBJECT not required, since we use the "templated QObject"

      {{public:    }}
          T value(){...}
      slot:
          set(T&& val){...}
      signal:
          valueChanged();

      private:
          T [[Qt::Property READ }}{{value}}{{ WRITE }}{{set NOTIFY }}{{valueChanged}}{{]] value_;
      // Alternatively:
      // #pragma Qt Property }}{{READ }}{{value{{ WRITE }}{{set NOTIFY }}{{valueChanged }}
      // }}{{T value_;
      };

      Attachments

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

        Activity

          People

            qtbuildsystem Qt Build System Team
            febbe Fabian Keßler
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes