QT动画里,一个状态的图片1,到下一个状态时,想换成另外一个图片2,可行吗?
做个动画,里面是一副图片,其中一个状态是图片1,想在状态2中,把图片换成另外一个,可以做到吗?
比如下面的代码里,state1时,button1的图片是SmallImage1,希望在state2里,图片换成其它的,可以做到吗?
QPalette pa;
QWidget *button1 = new QWidget;
QPixmap start_pixmap1=QPixmap(SmallImage1).scaled(m_nSmallImageW, m_nSmallImageH,Qt::IgnoreAspectRatio,Qt::FastTransformation);
pa.setBrush(QPalette::Background,QBrush(start_pixmap1));
button1->setPalette(pa);
。。。。
GraphicsScene scene(start_x, start_y, main_window_w, main_window_h);
scene.setBackgroundBrush(Qt::black);
scene.addWidget(button1);
。。。
state1 = createGeometryState(button1, QRect(positon1X, m_nSmallImageY, m_nSmallImageW, m_nSmallImageH),
button2, QRect(positon2X, m_nSmallImageY, m_nSmallImageW, m_nSmallImageH),
button3, QRect(positon3X, m_nSmallImageY, 0, 0),
group);
state2 = createGeometryState(button1, QRect(positon1X, m_nSmallImageY, m_nSmallImageW, m_nSmallImageH),
button2, QRect(positon3X, m_nSmallImageY, 0, 0),
button3, QRect(positon4X, m_nSmallImageY, m_nSmallImageW, m_nSmallImageH),
group);
group->setInitialState(state1);
QParallelAnimationGroup animationGroup;
QSequentialAnimationGroup *subGroup;