資源簡介
對應博文地址:http://blog.csdn.net/CSND_Ayo/article/details/70175385

代碼片段和文件信息
#include?
#include?
#ifndef?QT_NO_DEBUG
#include?
#endif
#include?“customdynamicwidget.h“
CustomDynamicWidget::CustomDynamicWidget(QWidget?*parent)?:?QWidget(parent)
????isLoop_(true)?currentIndex_(0)?{
}
void?CustomDynamicWidget::setAnimation(const?QPixmap?&_pix?const?short?_count?const?int?_msec)?{
????count_?=?_count;
????currentIndex_?=?0;
????if?(!pixList_.empty())?{
????????pixList_.clear();
????}
????else?{
????????/*??順時針動畫關聯??*/
????????clockTimer_?=?new?QTimer(this);
????????clockTimer_->setInterval(_msec);
????????connect(clockTimer_?SIGNAL(timeout())?this?SLOT(updateClockwise()));
????????/*??逆時針動畫關聯??*/
????????counterclockTimer_?=?new?QTimer(this);
????????counterclockTimer_->setInterval(_msec);
????????connect(counterclockTimer_?SIGNAL(timeout())?this?SLOT(updateCounterclockwise()));
????}
????/*??鏈式動畫圖標分離??*/
????for(short?i=0;?i?!=?_count;?++i)?{
????????pixList_.append(_pix.copy(i?*?(_pix.width()?/?_count)?0
????????????????????????_pix.width()?/?_count?_pix.height()));
????}
????currentPix_?=?pixList_.at(0);
????this->setGeometry(00currentPix_.width()currentPix_.height());
????update();
}
void?CustomDynamicWidget::startClockwise()?{
????/*??防止動畫錯亂??*/
????if(counterclockTimer_->isActive())?{
????????counterclockTimer_->stop();
????}
????else?{
????????currentIndex_?=?0;
????}
????clockTimer_->start();
}
void?CustomDynamicWidget::startCounterclockwise()?{
????/*??防止動畫錯亂??*/
????if(clockTimer_->isActive())
????{
????????clockTimer_->stop();
????}
????else?{
????????currentIndex_?=?count_?-?1;
????}
????if(currentIndex_?>?0)?{
????????counterclockTimer_->start();
????}
}
void?CustomDynamicWidget::stop()?{
????/*??停止動畫??*/
????if(clockTimer_->isActive())?{
????????clockTimer_->stop();
????}
????if(counterclockTimer_->isActive())?{
????????counterclockTimer_->stop();
????}
????/*??重置??*/
????currentIndex_?=?0;
????currentPix_?=?pixList_.at(0);
????update();
}
void?CustomDynamicWidget::updateClockwise(void)?{
????do?{
????????if?(currentIndex_?=?0)?{
????????????/*??更新幀??*/
????????????currentPix_?=?pixList_.at(currentIndex_);
????????????update();
????????????/*??判斷幀數??*/
????????????if?(currentIndex_?>=?(count_?-?1))?{
????????????????if(isLoop_)?{
????????????????????currentIndex_?=?0;
????????????????????return;
????????????????}
????????????????break;
????????????}
????????????/*??跳幀??*/
????????????++currentIndex_;
????????????return;
????????}
????????else?{
????#ifndef?QT_NO_DEBUG
????????????qDebug()?<????#endif
????????}
????}?while(false);
????clockTimer_->stop();
????currentIndex_?=?0;
????emit?clockwiseFinished();
}
void?CustomDynamicWidget::updateCounterclockwise()?{
????do?{
????????if(currentIndex_?>=?0?&&?currentIndex_?????????????/*??更新幀??*/
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????I.A....??????3992??2017-03-13?16:14??Animation\customdynamicwidget.cpp
????I.A....??????2465??2017-03-13?16:14??Animation\customdynamicwidget.h
????I.A....??????2806??2017-03-13?16:14??Animation\customprogressindicator.cpp
????I.A....??????2543??2017-03-13?16:14??Animation\customprogressindicator.h
????I.A....????????79??2017-05-23?09:48??Readme.md
?????目錄??????????0??2017-03-13?16:14??Animation
-----------?---------??----------?-----??----
????????????????11885????????????????????6
評論
共有 條評論