当前位置: 代码迷 >> QT开发 >> 窗口自动卡通型变化大小
  详细解决方案

窗口自动卡通型变化大小

热度:50   发布时间:2016-04-25 04:19:55.0
窗口自动动画型变化大小
就像拉拽窗口一会大一会小一样,怎么实现动画形式的变大变小啊???

用了

                QPropertyAnimation *animation = new QPropertyAnimation(parent, "geometry");
                animation->setDuration(3000);
                animation->setStartValue(QRect(100, 100,200, 200));
                animation->setEndValue(QRect(200, 100, 1000,1000));
                animation->setEasingCurve(QEasingCurve::Linear);
                animation->start();


结果只变化位置,不改变大小...
------最佳解决方案--------------------
Widget *w = new Widget;
w->show();

QPropertyAnimation *animation = new QPropertyAnimation(w, "geometry");
animation->setDuration(3000);
animation->setStartValue(QRect(100, 100,200, 200));
animation->setEndValue(QRect(200, 100, 1000,1000));
animation->setEasingCurve(QEasingCurve::Linear);
animation->start();


这段代码运行没有问题。
不知到LZ的parent到底是个什么东东。
------其他解决方案--------------------
我这可以实现阿

#include <QApplication>
#include <QPropertyAnimation>

int main(int argc,char *argv[])
{
    QApplication app(argc,argv);

    QWidget *w = new QWidget;
    w->show();

    QPropertyAnimation *animation = new QPropertyAnimation(w, "geometry");
    animation->setDuration(3000);
    animation->setStartValue(QRect(100, 100,200, 200));
    animation->setEndValue(QRect(200, 100, 1000,1000));
    animation->setEasingCurve(QEasingCurve::Linear);
    animation->start();

    return app.exec();
}

------其他解决方案--------------------
结贴是个好习惯
------其他解决方案--------------------
引用:
结贴是个好习惯



------其他解决方案--------------------
使用QTimer
定时器时间一到就调用resize
------其他解决方案--------------------
QPropertyAnimation *animation = new QPropertyAnimation(parent, "geometry");这个parent有问题吧?
------其他解决方案--------------------
timer好像是不行的。。。 不是动画的。

parent 是我传进来的 QWidget类指针。。
------其他解决方案--------------------
大小不能变化,有没有报什么错误
------其他解决方案--------------------
没有报错。。
parent是我传进来的。。。窗口地址

我就是想问问能不能改变大小
------其他解决方案--------------------
引用:
没有报错。。
  相关解决方案