tags:

views:

74

answers:

2

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.

A: 

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

Job
Yes, also you should consider that I know how to show a single picture like this:QImage image(fileName);imageLabel->setPixmap(QPixmap::fromImage(image));
Narek
So, what don't you know? You have to be more specific about your questions because I can see at least three different questions in yours (how to show an image, how to make something happen at intervals and how to create a link)...
Job
How to create a link? How to create an infinite loop of those pictures? And the last one: if .gif file is an animation the is will be animated on the QWidget?
Narek
Well, that looks like three separate questions than. None of which have anything to do with the title you gave it.
Job
+1  A: 

Hello,

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() fuction.

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 sublass the QLabel class and overrite 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!

cnebrera
It is not possible to set and QPixmap and text (with link) simultaneously.
Narek
Yep you are right. But there are other things you can do, you can subclass QLabel and overrite the mousePressEvent() and use QDesktopServices to open the link.
cnebrera