Results 1 to 7 of 7

Thread: Loading an image into memory

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Loading an image into memory

    You may only defer loading the pixmap to after you are sure the widget will already be visible. The latter happens when show() is called and processing returns to the event loop where appropriate events for showing the widget are processed. You can schedule your own event (or make a deferred slot call via QMetaObject::invokeMethod()) to load the image asynchronously. Of course you'll have to move all your code that uses the pixmap from the original function to somewhere after the pixmap is actually loaded.

  2. The following user says thank you to wysota for this useful post:

    Luc4 (10th April 2010)

  3. #2
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Loading an image into memory

    Thanks for the information! And is it possible to terminate the loading of an image? I noticed it is not possible to terminate a thread while it is loading an image (this time I'm using the read method of QImageReader). Even if I call the terminate, the image is loaded completely anyway.

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Loading an image into memory

    No, you can't interrupt the call as it's synchronous and performed mostly by 3rd party libraries that tend to behave differently.

  5. #4
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Loading an image into memory

    I'm trying to load the image from a separate thread with low priority. In this case, can I call the terminate method of the thread to interrupt the loading?
    Thanks again for your help!

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Loading an image into memory

    You can call it but it's unlikely it will actually terminate it inside the call

  7. #6
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Loading an image into memory

    OK, so no solution... :-( If I try to read an image which takes 8 seconds to load, I have to load it all, no matter what I do... Thanks anyway for your help!

Similar Threads

  1. loading image from disk
    By freekill in forum Qt Programming
    Replies: 1
    Last Post: 18th February 2010, 05:21
  2. problems loading an image .jpg
    By maider in forum Qt Programming
    Replies: 3
    Last Post: 14th December 2009, 11:57
  3. Image Loading
    By kavinsiva in forum Qt Programming
    Replies: 2
    Last Post: 11th August 2009, 08:00
  4. QTextEdit and delayed image loading
    By Vladimir in forum Qt Programming
    Replies: 5
    Last Post: 27th April 2007, 08:13
  5. Loading a custom image into a QPixmap
    By KShots in forum Qt Programming
    Replies: 12
    Last Post: 5th August 2006, 00:16

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.