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

QVariantAnimation should not be abstract

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P2: Important
    • 5.0.0
    • 4.6.3, 4.7.4, 4.8.3
    • None
    • all

    • caaeb2043541865ef7a9da424238d54b6556f8aa

    Description

      Currently, QVariantAnimation has one pure virtual method: updateCurrentValue(). That makes it impossible to use the class directly, even though the rest of the functionality suggests that that would be perfectly possible and useful even with an empty implementation of this method.

      I have a use case where I would like to use QVariantAnimation to animate an internal value in my class. I do not want to provide a property for it, as that would break encapsulation. QVariantAnimation provides a valueChanged() signal, which is perfectly suitable to animate my value through a private slot. Why then do I need to supply some arbitrairy implementation of updateCurrentValue? A virtual method is useful for subclassing, but a pure virtual one makes the class useless.

      I now use:

      class VariantAnimation : public QVariantAnimation
      {
      Q_OBJECT
      public:
      VariantAnimation(QObject* parent = 0):
      QVariantAnimation(parent) {}

      protected:
      virtual void updateCurrentValue(const QVariant& value)

      { Q_UNUSED(value); }

      };

      I would have expected to be able to use QVariantAnimation directly, without having to subclass it.

      Attachments

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

        Activity

          People

            mmutz Marc Mutz
            andre André Somers
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes