#include "elemultipng.h" #include #include #include #include EleMultiPng::EleMultiPng(QString dirPre, QJsonArray maps, QWidget *parent) : QWidget{parent} { int len = maps.size(); for(int i=0; i1)) { timerId = startTimer(picDur, Qt::PreciseTimer); startMove(); } QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform); painter.drawPixmap(imgx, imgy, imgs[imgc]); } void EleMultiPng::timerEvent(QTimerEvent *e) { if(isVisible()) { int id = e->timerId(); if(id==timerId){ if(imgc+2 > imgs.size()) imgc = 0; else imgc++; startMove(); } else if(id==moveTimerId){ if(effType=='l') { imgx -= movePx; if(imgx < 0) imgx = 0; } else if(effType=='t') { imgy -= movePx; if(imgy < 0) imgy = 0; } else if(effType=='r') { imgx += movePx; if(imgx > 0) imgx = 0; } else if(effType=='b') { imgy += movePx; if(imgy > 0) imgy = 0; } if(imgx==0 && imgy==0) { killTimer(moveTimerId); moveTimerId = 0; } } update(); } else { if(timerId!=0) { killTimer(timerId); timerId = 0; } if(moveTimerId!=0) { killTimer(moveTimerId); moveTimerId = 0; } } }