Solved QPropertyAnimation funktioniert nicht
-
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.
-
@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");
-
animation->setPropertyName() ist vermissed.
-
@JoeCFD Hi, ich denke nicht, dass das das Problem ist. Beim Erzeugen übergebe ich ja "maximumWidth". Aber ich werde es nachher mal testen.
-
@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");
-
-
@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"); -
@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 withauto
, but then your code would be a mess or at least harder to understand) -
@Pl45m4 new QPropertyAnimation sagt alles. Kein Problem hier. Ansonst hast Du recht.
-
@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.