Results 1 to 12 of 12

Thread: Timer delay

  1. #1
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Unhappy Timer delay

    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:
    Qt Code:
    1. void Custom_window::new_dialog()
    2. {
    3. list[0] = "/home/suresh/Desktop/Test/gui_client/newflower.png";
    4. list[1] = "/home/suresh/Desktop/Test/gui_client/mod_xfce-in-the-moon.png";
    5. list[2] = "/home/suresh/Examples/logo-Kubuntu.png";
    6. list[3] = "/usr/share/xfce4/backdrops/xfce-smoke.png";
    7. list[4] = "/usr/share/xfce4/backdrops/xubuntu-steel.png";
    8.  
    9. for(int i=0;i<5;++i)
    10. {
    11. QTimer *timer = new QTimer;
    12. QPixmap p(list[i]);
    13. p= p.scaled( old_window->width(), old_window->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    14. old_window->resize(500,480);
    15. old_window->setPixmap(p);
    16. timer->start(5000);
    17. connect(timer, SIGNAL(timeout()),old_window , SLOT(setPixmap(p)));
    18. }
    19.  
    20. }
    To copy to clipboard, switch view to plain text mode 


    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.
    Last edited by jpn; 29th May 2008 at 10:51. Reason: missing [code] tags

  2. #2
    Join Date
    Oct 2007
    Location
    Cracow
    Posts
    56
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Timer delay

    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
    Qt Code:
    1. connect(timer, SIGNAL(timeout()), // type is void
    2. old_window , SLOT(setPixmap(p))); // type is QPixmap, you put also here value not type
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Re: Timer delay

    How can I rectify this
    Can any one help me

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Timer delay

    Are you sure that you want 5 different timers which will all timeout at the same time, every 5s?
    J-P Nurmi

  5. #5
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Re: Timer delay

    My intention is to display the 5 images in a sequence juz like a movie.
    How can I perform this.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Timer delay

    How about QLabel and QMovie?
    J-P Nurmi

  7. #7
    Join Date
    Oct 2007
    Location
    Cracow
    Posts
    56
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Timer delay

    in your new_dialog() slot write only something like this
    Qt Code:
    1. QTimer *timer = new QTimer;
    2. timer->start( 5000 );
    3. connect( timer, SIGNAL( timeout() ), this , SLOT( changePixmap() ) );
    To copy to clipboard, switch view to plain text mode 
    and implement new slot changePixmap() where you will change pixmap

  8. The following user says thank you to mazurekwrc for this useful post:

    bmn (29th May 2008)

  9. #8
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Timer delay

    Quote Originally Posted by bmn View Post
    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:
    Qt Code:
    1. old_window->setPixmap(p);
    To copy to clipboard, switch view to plain text mode 

    (others have already solved the rest of the problem)

    Vycke

  10. #9
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Timer delay

    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....?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....?content=82221

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



    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...

  11. #10
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Re: Timer delay

    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 .

  12. #11
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Re: Timer delay

    Can anyone help me...
    I want to display sequence of frames stored in a queue as video.
    30 frames or images per second

  13. #12
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Timer delay

    Quote Originally Posted by bmn View Post
    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....?content=82221


    Qt Code:
    1. /* first you make a frame list : */
    2. QMap<int,VIFrame> playmovie;
    3.  
    4. VIFrame Ftoc;
    5. Ftoc.pos = playmovie.size(); /* position of frame 0= first */
    6. Ftoc.point = QPoint(0,0); /* qpoint to draw image */
    7. Ftoc.set_pics( small ); /* insert image data */
    8. Ftoc.play = 300; /* millisecond to play 1000 = 1 sec. */
    9. Ftoc.bg = QColor(Qt::black); /* background color from frame */
    10. Ftoc.maxframe = QRect(0,0,small.width(),small.height()); /* the big area
    11.  to use
    12.  or the largest image to display...
    13. */
    14.  
    15. playmovie.insert(Ftoc.pos,Ftoc);
    16.  
    17. /* now you can play the movie on speed you need on APNG label
    18. http://www.qt-apps.org/content/show.php/Apng++Frame+Label?content=82221
    19.  
    20. After you have compose the Animated PNG save on resource (like demo from label) and launch the play on labeb
    21. other way to compose frame :
    22. https://addons.mozilla.org/en-US/firefox/addon/5519
    23. is the same way .....
    24.  
    25. */
    To copy to clipboard, switch view to plain text mode 


    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.co...ameStructure.h


    The list is play on this way ....

    and loop forever if running is true

    Qt Code:
    1. void PMovie::NextFrame()
    2. {
    3. capturescreen = false;
    4. if (!running) {
    5. return;
    6. }
    7. if ( (current + 1) > movie->framecount() ) {
    8. current = 0;
    9. }
    10. VIFrame record = playmovie[current];
    11. if (record.mode == 404) {
    12. /* no background found on frame!!!! pos!! */
    13. setBackgroundRole(QPalette::Text);
    14. } else {
    15. setBackgroundRole(QPalette::Dark);
    16. }
    17. setWindowTitle(QString("Play frame nr.%1 / modus %2").arg(record.pos + 1).arg(record.mode));
    18. running = true;
    19. setPixmap ( record.videopix() );
    20. setScaledContents(false);
    21. current++;
    22. QTimer::singleShot(record.play, this, SLOT(NextFrame()));
    23. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Thread, Timer and Socket. Comuication problem
    By ^NyAw^ in forum Qt Programming
    Replies: 6
    Last Post: 17th January 2008, 16:48
  2. Timer for application
    By Zergi in forum Qt Programming
    Replies: 3
    Last Post: 26th December 2007, 22:21
  3. Thread(s) and socket, timer slots
    By stephdev1965 in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2006, 14:04
  4. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  5. Timer call
    By mahe2310 in forum Qt Programming
    Replies: 1
    Last Post: 28th March 2006, 08:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.