void smallPictureView::movItemPos(int i){ allPixItem.at(i)->show(); QTimeLine *timeLine = new QTimeLine(300); timeLine->setFrameRange(0, 300); midPixItemFlag->hide(); scene.setSceneRect(0,widheight-81,widwidth,48); //scene.setSceneRect(-widwidth/2, -24,widwidth,48); allAnimation.at(i)->setTimeLine(timeLine); allAnimation.at(i)->clear(); allAnimation.at(i)->setItem(allPixItem.at(i)); if(i<selectedNum){//left //将该项目的位置设置为给定的步长值到指定的点。 allAnimation.at(i)->setPosAt(1, QPointF((36+1)*(i-selectedNum-1)+width()/2.0,widheight-81)); }else if(i>selectedNum){//right //将该项目的位置设置为给定的步长值到指定的点。 allAnimation.at(i)->setPosAt(1, QPointF(3+(36+1)*(i-selectedNum)+width()/2.0,widheight-81)); }else{//selected if(selectedNum!=oldSelectNum){ midPixItemFlag->hide(); oldSelectNum = selectedNum; } //将该项目的位置设置为给定的步长值到指定的点。 allAnimation.at(i)->setPosAt(1, QPointF(3-18+(36+1)*(i-selectedNum)+width()/2.0,widheight-81)); connect(timeLine,SIGNAL(finished()),this,SLOT(timelineFinished())); } timeLine->start(); }
Base::Base(QWidget *w, int duration, int loopCount) : duration(duration), w(w){ timeLine = new QTimeLine(duration); timeLine->setFrameRange(0, 255); timeLine->setLoopCount(loopCount); connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(nextStep(int))); connect(timeLine, SIGNAL(finished()), this, SLOT(timelineFinished())); }