I am having name of images in a stringlist "imageList", stringlist "imageTypeList" to hold type of images and size of this list in "imageListSize" now i want to view the images one after other at the time lag of 5 seconds,i have written code to implement this,my images were residing on the server :
void Viewer::imageViewer()
{
timer->stop();
if(!imageList.isEmpty())
{
if(imageListSize>=0)
{
buffer.open(QIODevice::ReadWrite);
QString fileName = imagelist[imageListSize];
imageftp=new QFtp(this);
imageftp->connectToHost("190.111.111.1");
imageftp->login("user","passwd");
imageftp->cd("media");
imageftp->get(fileName, &buffer);
connect(imageftp, SIGNAL(commandFinished(int, bool)),this, SLOT(ftpCommandFinished(int, bool)));
}
}
}
void Viewer::ftpCommandFinished(int, bool)
{
timer=new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(imageViewer()));
timer->start(5000);
buffer.open(QIODevice::ReadWrite);
QByteArray data=buffer.data();
QByteArray type;
type.insert(0,imageTypeList[imageListSize]);
if(!imageftp->hasPendingCommands())
{
QImageReader reader(&buffer, type);
QImage image = reader.read();
imageui.imageLabel->setPixmap(QPixmap::fromImage(image));
idialog.show();
}
imageListSize--;
imageViewer();
}
Above code produces segmentation fault,help me out...
Bookmarks