Results 1 to 10 of 10

Thread: How to reuse a QImage in a While loop?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Posts
    11
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default How to reuse a QImage in a While loop?

    Hello everybody...

    I'm programming a tracking system... i'm using image sequences... i have a working application that shows the image sequence, this is the basic idea:

    Qt Code:
    1. While(condition)
    2. {
    3. <some code...>
    4.  
    5. image = new QImage(fileName);//fileName is changing on every loop with something like /home/image0001.bmp... image0002.bmp... etc
    6.  
    7. <some code to refresh screen and show the imagen...>
    8. }
    To copy to clipboard, switch view to plain text mode 
    But there's a problem... i create a new Qimage on every loop and increases the memory consumption... that's bad...

    Well... i need to load an image on every loop in the same QImage object (image), then set empty the image object to load next of the sequence and show it without increasing memory consumption...

    I think the better idea is something like:

    Qt Code:
    1. // in the .h file:
    2. QImage *image;
    3.  
    4. //in the .cpp file, in the constructor:
    5. image = new QImage(width, height, 32);//an empty image with some size
    6.  
    7. //then in the while loop:
    8. While(condition)
    9. {
    10. <some code...>
    11.  
    12. <here i need to load an image in "image" object...>
    13.  
    14. <some code to refresh screen and show the image...>
    15.  
    16. <finally i need to empty "image" object, because i'm gonna load in it the next image of the sequence...>
    17. }
    To copy to clipboard, switch view to plain text mode 
    The problem is... i don't know how to do that...

    Can you help me?

    I'm programming with C++/QT3

    Thank you anyway...

    Jose

    PS: Excuse me... but my english is really bad... hope you understand...
    Last edited by jpn; 3rd June 2008 at 07:20. Reason: missing [code] tags

Similar Threads

  1. Replies: 12
    Last Post: 7th September 2011, 16:37
  2. QShared
    By sabeesh in forum Qt Programming
    Replies: 11
    Last Post: 11th October 2007, 12:40
  3. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55
  4. While statement inside the main loop
    By OnionRingOfDoom in forum Qt Programming
    Replies: 4
    Last Post: 8th February 2006, 18:17

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
  •  
Qt is a trademark of The Qt Company.