If all pictures are preloaded
You only need to have two pictures loaded at any time - the one you are fading in, and the one you are fading out. In your timeout handler, when the opacity reaches 0 (or 1, whatever), just emit a signal or call a method to load the next image (and swap the pixmaps so that the one that was faded in is now the one to fade out):
pixmap1 = pixmap2;
pixmap2.load( nextFileName );
pixmap1 = pixmap2;
pixmap2.load( nextFileName );
To copy to clipboard, switch view to plain text mode
It is not necessary to have two QPainter instances in the paint event. Just change the opacity on a single QPainter instance between drawing the two pixmaps.
The only thing you might want to preload is the list of picture file names. And you don't really even need to do that - you can create a QDirIterator as a member of your class, and simply call QDirIterator::next():
pixmap1 = pixmap2;
if ( myDirIterator.hasNext() == false )
myDirIterator = QDirIterator( path-to-picture-directory ); // restart from the beginning
pixmap2.load( myDirIterator.next() );
pixmap1 = pixmap2;
if ( myDirIterator.hasNext() == false )
myDirIterator = QDirIterator( path-to-picture-directory ); // restart from the beginning
pixmap2.load( myDirIterator.next() );
To copy to clipboard, switch view to plain text mode
This code swaps the pixmaps, then checks to see if there are any files remaining in the list. If there are still files remaining, it loads the next one. If not, it resets the iterator back to the beginning and then loads the first one.
Bookmarks