Qt Forum

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

    Solved QPropertyAnimation funktioniert nicht

    German
    3
    8
    133
    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.
    • S
      sp3x last edited by

      Hallo,

      folgenden Cod ehab eich und bekomme die nachfolgende Fehlermeldung:

      /**
       * @brief MainMenuWidget::btnMenuClicked
       */
      void MainMenuWidget::btnMenuClicked()
      {
          qDebug() << this;
          QPropertyAnimation animation = new QPropertyAnimation(this, "maximumWidth");
          animation.setDuration(500);
      
          if(isMaximized()) {
              setProperty("defaultWidth", width());
              //setMaximumWidth(m_config["minimizedWidth"].toInt());
              animation.setStartValue(width());
              animation.setEndValue(m_config["minimizedWidth"].toInt());
          } else {
              //setMaximumWidth(property("defaultWidth").toInt());
              animation.setStartValue(width());
              animation.setEndValue(property("defaultWidth").toInt());
          }
      
          animation.start(QAbstractAnimation::DeleteWhenStopped);
      }
      

      Die Konsolenausgabe dazu ist:

      MainMenuWidget(0x26eb99ac210, name="menuContainer")
      QPropertyAnimation::updateState (): Changing state of an animation without target
      

      Ich verstehe es nicht. Das Object in "this" hat geerbt von QWidget.

      Ich wäre dankbar für eure Hilfe.

      JoeCFD S 2 Replies Last reply Reply Quote 0
      • S
        sp3x @sp3x last edited by

        @sp3x said in QPropertyAnimation funktioniert nicht:

        QPropertyAnimation animation = new QPropertyAnimation(this, "maximumWidth");

        Ohmann, das Problem liegt hier:

        QPropertyAnimation animation = new QPropertyAnimation(this, "maximumWidth");
        

        Das Sternchen bei der declaration als Pointer hat gefehlt.

        So is richtig:

        QPropertyAnimation* animation = new QPropertyAnimation(this, "maximumWidth");
        
        JoeCFD 1 Reply Last reply Reply Quote 1
        • JoeCFD
          JoeCFD @sp3x last edited by

          animation->setPropertyName() ist vermissed.

          S 1 Reply Last reply Reply Quote 0
          • S
            sp3x @JoeCFD last edited by

            @JoeCFD Hi, ich denke nicht, dass das das Problem ist. Beim Erzeugen übergebe ich ja "maximumWidth". Aber ich werde es nachher mal testen.

            1 Reply Last reply Reply Quote 0
            • S
              sp3x @sp3x last edited by

              @sp3x said in QPropertyAnimation funktioniert nicht:

              QPropertyAnimation animation = new QPropertyAnimation(this, "maximumWidth");

              Ohmann, das Problem liegt hier:

              QPropertyAnimation animation = new QPropertyAnimation(this, "maximumWidth");
              

              Das Sternchen bei der declaration als Pointer hat gefehlt.

              So is richtig:

              QPropertyAnimation* animation = new QPropertyAnimation(this, "maximumWidth");
              
              JoeCFD 1 Reply Last reply Reply Quote 1
              • Topic has been marked as solved  S sp3x 
              • JoeCFD
                JoeCFD @sp3x last edited by

                @sp3x said in QPropertyAnimation funktioniert nicht:

                QPropertyAnimation* animation = new QPropertyAnimation(this, "maximumWidth");

                Ich habe es auch nicht gesehen. Wie konntest Du Dein Code kompilieren? Gab es keine Fehlermeldung?

                Mit auto kannst Du das gleiche Problem vermeiden.
                auto animation = new QPropertyAnimation(this, "maximumWidth");

                Pl45m4 S 2 Replies Last reply Reply Quote 0
                • Pl45m4
                  Pl45m4 @JoeCFD last edited by

                  @JoeCFD said in QPropertyAnimation funktioniert nicht:

                  Mit auto kannst Du das gleiche Problem vermeiden.

                  Ist das nicht eine schlechte Angewohnheit auto zu oft zu nutzen?

                  (Isn't this a bad habit/style to use auto too often? In theory, you could replace almost every variable with auto, but then your code would be a mess or at least harder to understand)


                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                  ~E. W. Dijkstra

                  JoeCFD 1 Reply Last reply Reply Quote 0
                  • JoeCFD
                    JoeCFD @Pl45m4 last edited by JoeCFD

                    @Pl45m4 new QPropertyAnimation sagt alles. Kein Problem hier. Ansonst hast Du recht.

                    1 Reply Last reply Reply Quote 1
                    • S
                      sp3x @JoeCFD last edited by sp3x

                      @JoeCFD genau die Frage habe ich mir auch gestellt! Kann ich nicht beantworten. Hat so ohne Fehler oder Warnung funktioniert. Eigentlich nicht möglich. Vielleicht hab ich noch nen Bock drinne gehabt.

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