PDA

View Full Version : Timer delay



bmn
29th May 2008, 10:50
I am trying to implement a GUI having some push buttons & a window to display image.
There are two buttons Start & Stop
When the start button is pushed, a sequence of images stored in an array of QString has to be displayed.
When Start button is pushed, new_dialog() Slot is called.
The code for new_dialog() is as follows:

void Custom_window::new_dialog()
{
list[0] = "/home/suresh/Desktop/Test/gui_client/newflower.png";
list[1] = "/home/suresh/Desktop/Test/gui_client/mod_xfce-in-the-moon.png";
list[2] = "/home/suresh/Examples/logo-Kubuntu.png";
list[3] = "/usr/share/xfce4/backdrops/xfce-smoke.png";
list[4] = "/usr/share/xfce4/backdrops/xubuntu-steel.png";

for(int i=0;i<5;++i)
{
QTimer *timer = new QTimer;
QPixmap p(list[i]);
p= p.scaled( old_window->width(), old_window->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
old_window->resize(500,480);
old_window->setPixmap(p);
timer->start(5000);
connect(timer, SIGNAL(timeout()),old_window , SLOT(setPixmap(p)));
}

}


The problem I was facing is that I was able to display only the last frame.
And the error I am facing is
Object::connect: No such slot QLabel::setPixmap(p)
But I was able to see the last image.

mazurekwrc
29th May 2008, 11:01
you get error because


The signals and slots mechanism is type safe: The signature of a signal must match the signature of the receiving slot.

and you use

connect(timer, SIGNAL(timeout()), // type is void
old_window , SLOT(setPixmap(p))); // type is QPixmap, you put also here value not type

bmn
29th May 2008, 11:06
How can I rectify this
Can any one help me

jpn
29th May 2008, 11:10
Are you sure that you want 5 different timers which will all timeout at the same time, every 5s?

bmn
29th May 2008, 11:16
My intention is to display the 5 images in a sequence juz like a movie.
How can I perform this.

jpn
29th May 2008, 11:20
How about QLabel and QMovie?

mazurekwrc
29th May 2008, 11:24
in your new_dialog() slot write only something like this


QTimer *timer = new QTimer;
timer->start( 5000 );
connect( timer, SIGNAL( timeout() ), this , SLOT( changePixmap() ) );

and implement new slot changePixmap() where you will change pixmap

vycke
29th May 2008, 13:53
I am trying to implement a GUI having some push buttons & a window to display image.

<snip>

The problem I was facing is that I was able to display only the last frame.
And the error I am facing is
Object::connect: No such slot QLabel::setPixmap(p)
But I was able to see the last image.

Btw, you were able to see the last image because of:


old_window->setPixmap(p);


(others have already solved the rest of the problem)

Vycke

patrik08
30th May 2008, 18:23
Now you can take all your image on png format

Compose a new APNG image ( Animated Portable Network Graphics )
on tool ...
http://www.qt-apps.org/content/show.php/APNG+Image%2BVideo+format+assembler?content=81573
or
https://addons.mozilla.org/en-US/firefox/addon/5519

Compression & quality are incredible...

Or you take the class and lib & build your own editor...


and play all on a QT Label
http://www.qt-apps.org/content/show.php/Apng++Frame+Label?content=82221

And all advanced WebBrowser can play its
IMO: favicon icon ( to webpage) Animated ... are possibel..

http://ppk.ciz.ch/qt_c++/apng_format/Animated_PNG_example_bouncing_beach_ball.png

swap to firefox or opera if the ball here not bounce...

MNG image Format is not supported from web browser and is not simple to compose... a lot of chunk...

bmn
2nd June 2008, 12:54
I was able to show sequence of frames, i.e 3 frames in one second approx.
But I want to display 32 frames in one second & also all the frames are stored in a queue .

bmn
3rd June 2008, 10:10
Can anyone help me...
I want to display sequence of frames stored in a queue as video.
30 frames or images per second

patrik08
3rd June 2008, 11:54
Can anyone help me...
I want to display sequence of frames stored in a queue as video.
30 frames or images per second

Have a look on the code from :
http://www.qt-apps.org/content/show.php/Apng++Frame+Label?content=82221




/* first you make a frame list : */
QMap<int,VIFrame> playmovie;

VIFrame Ftoc;
Ftoc.pos = playmovie.size(); /* position of frame 0= first */
Ftoc.point = QPoint(0,0); /* qpoint to draw image */
Ftoc.set_pics( small ); /* insert image data */
Ftoc.play = 300; /* millisecond to play 1000 = 1 sec. */
Ftoc.bg = QColor(Qt::black); /* background color from frame */
Ftoc.maxframe = QRect(0,0,small.width(),small.height()); /* the big area
to use
or the largest image to display...
*/

playmovie.insert(Ftoc.pos,Ftoc);

/* now you can play the movie on speed you need on APNG label
http://www.qt-apps.org/content/show.php/Apng++Frame+Label?content=82221

After you have compose the Animated PNG save on resource (like demo from label) and launch the play on labeb
other way to compose frame :
https://addons.mozilla.org/en-US/firefox/addon/5519
is the same way .....

*/




void set_pics( const QByteArray bytes ); /* QByteArray from image contenent as png */
void set_pics( QPixmap barcode );
void set_pics( const QPixmap * barcode );
/* you can extended to insert other image type ...*/


search " VIFrame "
on file ...
http://fop-miniscribus.googlecode.com/svn/trunk/apng_label/src/InternalFrameStructure.h


The list is play on this way ....

and loop forever if running is true




void PMovie::NextFrame()
{
capturescreen = false;
if (!running) {
return;
}
if ( (current + 1) > movie->framecount() ) {
current = 0;
}
VIFrame record = playmovie[current];
if (record.mode == 404) {
/* no background found on frame!!!! pos!! */
setBackgroundRole(QPalette::Text);
} else {
setBackgroundRole(QPalette::Dark);
}
setWindowTitle(QString("Play frame nr.%1 / modus %2").arg(record.pos + 1).arg(record.mode));
running = true;
setPixmap ( record.videopix() );
setScaledContents(false);
current++;
QTimer::singleShot(record.play, this, SLOT(NextFrame()));
}