prophet0
5th December 2011, 21:17
header file
public:
QStringListIterator *iterator;
QTimer *timer;
public slots:
void slide();
private:
QLabel *picture;
cpp file
picture = new QLabel(this);
picture->setGeometry(QRect(781,2,475,360));
picture->show();
QDir dir("/home/dev/ttm/images/");
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
QStringList files = dir.entryList();
QStringList fileNames;
foreach (QString f, files)
fileNames << (dir.absolutePath() + QDir::separator() + f);
iterator = new QStringListIterator(fileNames);
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(slide()));
timer->start(6000);
void mediazone::slide()
{
if(iterator->hasNext())
{
picture->clear();
picture->setPixmap(QPixmap(iterator->next()));
picture->show();
}
}
I want to make this loop once it hits the last file in the list how would i go about doing so thanks
public:
QStringListIterator *iterator;
QTimer *timer;
public slots:
void slide();
private:
QLabel *picture;
cpp file
picture = new QLabel(this);
picture->setGeometry(QRect(781,2,475,360));
picture->show();
QDir dir("/home/dev/ttm/images/");
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
QStringList files = dir.entryList();
QStringList fileNames;
foreach (QString f, files)
fileNames << (dir.absolutePath() + QDir::separator() + f);
iterator = new QStringListIterator(fileNames);
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(slide()));
timer->start(6000);
void mediazone::slide()
{
if(iterator->hasNext())
{
picture->clear();
picture->setPixmap(QPixmap(iterator->next()));
picture->show();
}
}
I want to make this loop once it hits the last file in the list how would i go about doing so thanks