0
要动画我用这个代码的QPixmap:如何动画一个QPixmap的另一QPixmap的内侧QPropertyanimation
QLabel *label = new QLabel(this);
QPixmap image = QPixmap("C://save.png");
image = image.scaledToHeight(40,Qt::SmoothTransformation);
label->setPixmap(image);
//...
//...
QPropertyAnimation* animation = new QPropertyAnimation(label, "geometry");
animation->setDuration(10000);
animation->setStartValue(QRect(0, 0, 40, 40));
animation->setEndValue(QRect(250, 250,40, 40));
animation->start();
因此,在这个例子中,我的动画一个QLabel里面一个QPixmap的,但是这不是我想做的事现在,我想在另一个QPixmap中为QPixmap制作动画,因为我希望能够将QPixmap(包含所有动画QPixmaps)导出到QImage中(所以我想做一个截图)。
QPropertyAnimation可以做到吗?如果没有,我会编写我自己的动画课程。
不确定你想要什么。如果你想用widgets做到这一点,看看['QWidget :: grab()'](http://doc.qt.io/qt-5/qwidget.html#grab)。当然,生成的像素图可以转换为图像。但是,如果你想完全避开小部件,你可以使用'QPainter'在pixmap上绘制一个像素图。但对于动画,你不能使用'QPropertyAnimation'。 – leemes
非常感谢,QWidget :: grab()正是我所搜寻的:) –