enum Typeanim{chsize, chpos}; // Перегруженная функция анимации объекта obj, изменение координат ИЛИ размераvoid Animation::animateObject(QWidget *obj, Typeanim typeanim, unsigned duration, QEasingCurve easingcurve, int startX, int startY, int endX, int endY){ QPropertyAnimation *anim = new QPropertyAnimation(obj, "geometry"); anim->setDuration(duration); anim->setEasingCurve(easingcurve); if(typeanim == chsize){ QPoint pos = obj->pos(); anim->setStartValue(QRect(pos.x(), pos.y(), startX, startY)); anim->setEndValue(QRect(pos.x(), pos.y(), endX, endY)); } else { QSize sizeobj = obj->size(); anim->setStartValue(QRect(startX, startY, sizeobj.width(), sizeobj.height())); anim->setEndValue(QRect(endX, endY, sizeobj.width(), sizeobj.height())); } anim->start(QAbstractAnimation::DeleteWhenStopped); return;}
no matching function for call to 'QPropertyAnimation::QPropertyAnimation(QWidget*&, const char [9])' QPropertyAnimation *anim = new QPropertyAnimation(obj, "geometry");variable 'QSize sizeobj' has initializer but incomplete type QSize sizeobj = obj->size();invalid use of incomplete type 'class QWidget' QSize sizeobj = obj->size();invalid use of incomplete type 'class QRect' anim->setStartValue(QRect(startXpos, startYpos, sizeobj.width(), sizeobj.height()));
#include <QPropertyAnimation>
#ifndef ANIMATION_H#define ANIMATION_H#include <QObject>#include <QPropertyAnimation>enum Typeanim{chsize, chpos}; class Animation : public QObject{ Q_OBJECT public: explicit Animation(QObject *parent = 0); protected: // Перегруженная функция анимации объекта obj, изменение координат void animateObject(QWidget *obj, unsigned duration, QEasingCurve typeanim, int startXpos, int startYpos, int endXpos, int endYpos); // Перегруженная функция анимации объекта obj, изменение координат и размера void animateObject(QWidget *obj, unsigned duration, QEasingCurve typeanim, int startXpos, int startYpos, int endXpos, int endYpos, int startXsize, int startYsize, int endXsize, int endYsize);};#endif // ANIMATION_H
#include "animation.h"// КонструкторAnimation::Animation(QObject *parent) : QObject(parent){}// Перегруженная функция анимации объекта obj, изменение координат ИЛИ размераvoid Animation::animateObject(QWidget *obj, Typeanim typeanim, unsigned duration, QEasingCurve easingcurve, int startX, int startY, int endX, int endY){ QPropertyAnimation *anim = new QPropertyAnimation(obj, "geometry"); anim->setDuration(duration); anim->setEasingCurve(easingcurve); if(typeanim == chsize){ QPoint pos = obj->pos(); anim->setStartValue(QRect(pos.x(), pos.y(), startX, startY)); anim->setEndValue(QRect(pos.x(), pos.y(), endX, endY)); } else { QSize sizeobj = obj->size(); anim->setStartValue(QRect(startX, startY, sizeobj.width(), sizeobj.height())); anim->setEndValue(QRect(endX, endY, sizeobj.width(), sizeobj.height())); } anim->start(QAbstractAnimation::DeleteWhenStopped); return;}// Перегруженная функция анимации объекта obj, изменение координат И размераvoid Animation::animateObject(QWidget *obj, unsigned duration, QEasingCurve easingcurve, int startXpos, int startYpos, int endXpos, int endYpos, int startXsize, int startYsize, int endXsize, int endYsize){ QPropertyAnimation *anim = new QPropertyAnimation(obj, "geometry"); anim->setDuration(duration); anim->setEasingCurve(easingcurve); anim->setStartValue(QRect(startXpos, startYpos, startXsize, startYsize)); anim->setEndValue(QRect(endXpos, endYpos, endXsize, endYsize)); anim->start(QAbstractAnimation::DeleteWhenStopped); return;}
void animateObject(QWidget *obj, unsigned duration, QEasingCurve typeanim, int startXpos, int startYpos, int endXpos, int endYpos);
Animation::animateObject(QWidget *obj, Typeanim typeanim, unsigned duration, QEasingCurve easingcurve, int startX, int startY, int endX, int endY)