×
Namespaces

Variants
Actions

How to use QMovie in Qt

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Qt Creator IDE V4.5 & S60 5th edition
Compatibility
Platform(s): Qt
Symbian
Article
Keywords: QMovie,QSlider,QPushButton
Created: mind_freak (18 Mar 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

Overview

This is generally used to play any kind of animated images.QMovie

When you press play the animation starts playing,when slider value is increase the animation speed get faster.

Preconditions

Comptability

  • Can be executed on Qt Creator V4.5 IDE as well as Symbian platform

Various Functions

  • Sets the name of the file that QMovie reads image data from
movie->setFileName(QString str);
  • Sets the format that QMovie will use when decoding image data
movie->setFormat(const QByteArray & format);
  • Sets the scaled frame size to size.
QMovie *movie = new QMovie("c:\\data\\images\\canadagoose.gif");
QSize size(200,200);
movie->setScaledSize(size);

Movui.JPG

Source Code

#include <QtGui/QApplication>
#include "widget.h"
#include<QWidget>
#include<QHBoxLayout>
#include<QLabel>
#include<QMovie>
#include<QPushButton>
#include<QSlider>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *win=new QWidget();
QHBoxLayout *lay=new QHBoxLayout();
QPushButton *play=new QPushButton("PLAY");
QPushButton *stop=new QPushButton("STOP");
QSlider *slider=new QSlider();
slider->setMinimum(0);
slider->setMaximum(200);
QLabel *label=new QLabel;
QMovie *movie = new QMovie("C://Documents and Settings//Viral//My Documents//Qerrormsg//Movie//canadagoose.gif");
label->setMovie(movie);
QObject::connect(play,SIGNAL(clicked()),movie,SLOT(start()));
QObject::connect(stop,SIGNAL(clicked()),movie,SLOT(stop()));
QObject::connect(slider,SIGNAL(valueChanged(int)),movie,SLOT(setSpeed(int)));
lay->addWidget(label);
lay->addWidget(play);
lay->addWidget(stop);
lay->addWidget(slider);
win->setLayout(lay);
win->show();
return a.exec();
}

Screenshot

More About QMovie visit:QMovie

Impvira.JPG

More About QMovie visit:QMovie

This page was last modified on 11 October 2012, at 04:17.
161 page views in the last 30 days.