Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    What about Property animation with GraphicsItem

    General and Desktop
    2
    8
    1084
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User last edited by

      Hello World!

      Have 5.3.0
      @
      class myTextItem: public QObject, public QGraphicsTextItem
      {
      Q_OBJECT
      Q_PROPERTY(QPointF newPos READ pos WRITE setPos)
      Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth)
      }
      @
      and compile
      4x 'QObject' is an ambiguous base of 'myTextItem'

      P.S.0 http://qt-project.org/doc/qt-4.8/animation-overview.html
      P.S.1 i think it posible only 4.8

      have any ideas?

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        The animation framework is still valid, and it works in exactly the same way in Qt 5, as it did in Qt 4.

        In this case, instead of subclassing QObject, you can use QVariantAnimation class to animate your properties.

        (Z(:^

        1 Reply Last reply Reply Quote 0
        • ?
          A Former User last edited by

          [quote author="sierdzio" date="1411976308"]The animation framework is still valid, and it works in exactly the same way in Qt 5, as it did in Qt 4.

          In this case, instead of subclassing QObject, you can use QVariantAnimation class to animate your properties.[/quote]

          xmmm

          you offer subclassing of QVariantAnimation?
          or
          only "public: QGraphicsTextItem"

          and in main instead QPropertyAnimation use QVariantAnimation?

          =D in first case i still get ‘QObject’ is an ambiguous base of ‘myTextItem’
          but now 2x

          1 Reply Last reply Reply Quote 0
          • sierdzio
            sierdzio Moderators last edited by

            I propose to go with the second option: only inherit from QGraphicsTextItem.

            (Z(:^

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User last edited by

              if only “public: QGraphicsTextItem”
              and use macro Q_OBJECT
              clean - rebuild
              all work

              1 Reply Last reply Reply Quote 0
              • sierdzio
                sierdzio Moderators last edited by

                Do not use Q_OBJECT macro in there. Variant animation does not need it. Remove Q_PROPERTY macros, too.

                (Z(:^

                1 Reply Last reply Reply Quote 0
                • ?
                  A Former User last edited by

                  wherefore QVariantAnimation better?

                  if add that macro i can use QPropertyAnimation (i think it simple for use
                  and more flexibly if use property)

                  but i newbie and i wait you answer =)

                  1 Reply Last reply Reply Quote 0
                  • sierdzio
                    sierdzio Moderators last edited by

                    QPropertyAnimation class, Q_OBJECT and Q_PROPERTY macros are reserved for QObjects. If it works for you without a QObject, well, I am surprised - it shouldn't, but you can probably leave it as it is.

                    (Z(:^

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post