PDA

View Full Version : how to add .giff or .avi files in app



thomasjoy
1st August 2007, 09:48
hi all
i am working on Qt4.1 using Mac OsX Platform
i want to know how the support of .giff and .avi files are given to app


thanks in advance

marcel
1st August 2007, 09:55
GIF is supported through a plugin, but it is not automatically compiled because of patent issues.
If you have the commercial edition, the you have it, otherwise if you did not select it when you compiled Qt you will have to reconfigure and recompile.

AVI is not supported by Qt.

Regards

thomasjoy
1st August 2007, 10:47
does QT 4.1 support any other moving files like giff or avi???
if any please do mention

thaks in advance

marcel
1st August 2007, 10:52
Maybe you can do something with the QMovie class.
It is used to display GIF animations.

As I said before, AVI is not supported in Qt. But there are third party libraries out there which you can integrate.


Regards

thomasjoy
1st August 2007, 13:00
which types of format QMovie can support...??
can you please list it down..

if it support .gif then how ??
can you tell me example code another than te QT manual code...means to say simple example where i am importing any .gif images i.e as i click to the .app directly .gif image start playing ..

as i had try to create
------------
form.cpp
-----------
#include <QMovie>

void form:: imageStart()
{

movie = new QMovie("/background/mime-attachment.gif");
label->setMovie(movie);
movie->start();


}
---------
form.h
---------

connect( movie,SIGNAL(started()),this,SLOT(imageStart()) );
or is there any process or signal

thanks in advance

marcel
1st August 2007, 13:06
First add a label to your window.

Then use your existing movie code to attach it to that label.

You can call movie->start() as a result of an action or a button click.
For example if you have a button in your window, you can do the following:


connect( button, SIGNAL(clicked()), movie, SLOT(start()));

But be careful to create the movie object before connecting.

Pretty much this is it...


Regards

thomasjoy
1st August 2007, 13:24
as i had try to use ur code like this
everything i had placed in form.h
but as i click button nothing happened

see the .h

class form :: public QDialog,private Ui::form
{

Q_OBJECT
public:
form::form(QWidget *parent): QDialog(parent)
{
setupUi(this);
QMovie *movie = new QMovie("/background/mime-attachment.gif");
label->setMovie(movie);
movie->start();
connect( pushButton,SIGNAL(clicked()),movie,SLOT(start()) );
//QPixmap pixmap("/background/wizard-big-2.png");
//label->setPixmap(pixmap);
};


thanks in advance







};

marcel
1st August 2007, 13:39
Remove the line movie->start().
The start() slot just starts the animation. You do this by pressing the button.

Other than that, the code looks OK. Make sure that the path to the GIF is correct. Try giving the absolute file path, just to make sure it is loaded. It should work with your code.

Regarding your question about other animation means in Qt:
There is another one: The QSvgRenderer class. It supports animated SVGs. It is more advanced than the QMovie, since you basically can paint the svg on almost everything. Also , the SVG format overcomes many of the GIF drawbacks.

To update the animation, the renderer provides the repaintNeeded() signal. This means that you need to render the svg again, since a new frame is available.


Regards

thomasjoy
1st August 2007, 15:05
if i dont have the -qt-gif support at time of configuration then what i have to do so that image should be moved as gif image move...

and as manual saying gif support will be completly removed in upcomings of qt versions so is it benificial...?? if not then what i have to do???

or what another way is,except QSvgRenderer class as it seems that these pictures made in gimpshop..

is it possible that in every second like 1,2,3 .....after completion of every second image should be change ???
like you can take an example when 1 second complete bulb image should be on,
and after next second it should be off and next second again on ,then off-on,off-on
....so on till some process not completed((at starting it should be off)??

if yes then tell me in simple example....

thanks in advance

marcel
1st August 2007, 15:17
if i dont have the -qt-gif support at time of configuration then what i have to do so that image should be moved as gif image move...

You could recompile Qt with GIF support...



or what another way is,except QSvgRenderer class as it seems that these pictures made in gimpshop..

None built in.
You can create svg's with many applications. A very good one is Inkscape and it is opensource.



s it possible that in every second like 1,2,3 .....after completion of every second image should be change ???

Yes, it is possible with a QSvgRenderer.
Just prepare a svg and load it.
Next call QSvgRender::setFramesPerSecond(1). This means a frame every second.
So, every second you will get a repaint needed signal from the renderer, notifying you that a new frame is ready to be rendered.

Regards

thomasjoy
1st August 2007, 15:48
does QSvgRenderer only support svg files...if no then what kinds of images it support or
list of supported image formats for this class??

is it support .png if not then tell the same for .pngs


s it possible that in every second like 1,2,3 .....after completion of every second image should be change ???
like you can take an example when 1 second complete bulb image should be on,
and after next second it should be off and next second again on ,then off-on,off-on
....so on till some process not completed((at starting it should be off)??

thanks in advance

marcel
1st August 2007, 15:53
No, only svg files.

PNG is supported by QPixmap and QImage, but the png format itself does not support animation.

You could do something about this. F.e. load a series of png images and display them in a widget with a certain delay.

Regards

thomasjoy
1st August 2007, 15:53
and as manual saying gif support will be completly removed in upcomings of qt versions so is it benificial...?? if not then what i have to do???

as in windows .png image can be changed for every second till process doesn't end..
so for same i wanna get the solution.

marcel
1st August 2007, 16:15
as in windows .png image can be changed for every second till process doesn't end..
so for same i wanna get the solution.

I suppose you could write your own small animation framework based on png frames.
As I told you, you can load a PNG with a QPixmap. You can display the pixmap on a standard QWidget, or even on a QLabel, with setPixmap.

Also, read about QTimeLine. It is meant for animations.

Regards