void MainWindow::NextImage(){
switch(currentImageNo){
case 0:
//set 1st image
break;
case 1:
//set 2nd image
break;
case 2:
//set 3rd image
break;
...
}
timer.setInterval( /*your desired new interval based on currentImageNo*/ );
currentImageNo++;
//in order to loop back to the first image after the last image is shown
currentImageNo= currentImageNo % numberOfImages;
}
in your MainWindow的构造函数,创建一个QTimer与您想要的间隔并连接它timeout()向NextImage上面定义的槽
MainWindow::MainWindow(){
...
timer= new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(NextImage()));
timer.setSingleShot(false);
timer.setInterval(5000); //5 secs for first image
timer.start();
NextImage(); //to load the first image initially
}
记得声明并初始化currentImageNo, numberOfImages and timer作为你的成员MainWindow class.