Question

I have a directroy where I have several pictures and gif animations. I want to post that pictures and animations on a QDialog in an infinite loop (by cyclically changing pictures in 2 minutes interval) and on that pictures and animations I want to set a link so that when you click the browser open the set link.

How I could do this?

Please consider that I know how to get all .jpg amd .gif file names (full path) in the directory. Consider there is a QStringList fileNameList; which contains that full paths.

Was it helpful?

Solution

You can use 2 QLabels for this. The first one will be used for static images like jpg and the second one for animations. In the first one you can use setPixmap to set the image and in the second one you need to create a QMovie object giving it the gif file in the constructor. Once the object is created you can assign the movie to a label using the setMovie() function.

The movie doesn't start until you call start() in the QMovie object.

With this you have animations and static images. Since you want then change every 2 seconds I would suggest to store all the file names in a QList and then use a QTimer to read the next file name and load it in one of the labels (the one for static images or the other) and hide the one that is not going to be visible.

To open links you can subclass the QLabel class and override the mousePressEvent method. Inside the method you can call QDesktopServices::openExternalLink(link). You can add the link as a member of your subclass.

Good luck!

OTHER TIPS

You can use QLabel::setPixmap to show an image in a label.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top