I have to display a number of images from a folder in bin onto a label or any other widget with an alterable frame rate??
I have to display a number of images from a folder in bin onto a label or any other widget with an alterable frame rate??
What have you tried?
thanx for showing concern...............................
I am able to display a single image from a folder onto a label but don't know how to go beyond that. I mean how would I get a slide show kind of a thing??
Have a look at QTimer
Also if you are using 4.6.3, you have animation classes,, but try the timer thing first
Create a QTimer, connect its timeout() signal to the slot in which you'll change the images. In such slot you should use setPixmap function.
Example:
Qt Code:
connect(slideShow,SIGNAL(timeout()),this,SLOT(changePixmap())); //... MainWindow::changePixmap() { imgNum = (imgNum + 1) % 10 //for a series of 10 images with names "imageName(0-9).ext" }To copy to clipboard, switch view to plain text mode
I have implemented it as :
// MainWindow.cpp consists of this snippet:
QTimer *timer = new QTimer;
QStringList fileName = QFileDialog::getOpenFileNames(this,
tr("Open Image"), "C:/qt-win-opensource-src-4.5.0/bin/", tr("Image Files (*.png *.jpg *.bmp *.avi *.gif)"));
QStringListIterator iterator(fileName);
label = new QLabel;
connect(timer,SIGNAL(timeout()),this,SLOT(nextPict ure(QStringListIterator&)));
timer->start(5000);
//And the slot nextPicture is defined as:
void MainWindow::nextPicture(QStringListIterator& iterator)
{
if(iterator.hasNext())
{
label->clear();
label->setPixmap(QPixmap(iterator.next()));
workspace->addWindow(label);
label->show();
}
}
But this is not displaying even a single image(which was getting displayed earlier).
Thanx in advance.
You cannot connect that. It must be returning false.connect(timer,SIGNAL(timeout()),this,SLOT(nextPict ure(QStringListIterator&)));
The slot MUST have equal to or less than arguments than the signal, and each argument matching like in functions..
Bookmarks