Results 1 to 4 of 4

Thread: QML - load multiple Images simultaneously

  1. #1

    Default QML - load multiple Images simultaneously

    Hi guys,

    I'm currently trying to move an existing application I have that is based on QWidgets over to QML. I was hesitant at first, but QML does work rather well for this app. However, I do have one slight "problem" or drawback at the moment:

    In my application I load a bunch of images as thumbnails in a ListView (a bunch of Image elements aligned in a Row). I really like the ImageProvider feature of QML, it's really handy! However, it seems to be a little slower than what I had before in pure C++/QWidgets, even though the ImageProvider I'm using makes use of almost exactly the same code I used before to load the thumbnails (it's basically a simple scaling, database caching, returning).

    So, my question is this: Does anybody know if it's possible to load multiple images simultaneously? At the moment, it loads one image at a time. However, the slow part of the ImageProvider are (I guess) the scaling and caching. Since pretty much all computers nowadays have several CPU Cores available, I'm thinking, that loading 2/3/4 images simultaneously would be significantly faster than one at a time...

    Thanks guys!

    huilui

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

    Default Re: QML - load multiple Images simultaneously

    If you are doing scaling at C++ level then it is not worth it. If you scale the image in QtQuick, you will get it almost for free as the GPU will scale the texture much faster than your CPU will scale the bitmap.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3

    Default Re: QML - load multiple Images simultaneously

    Well, what I did just now, is, timing every line of the ImageProvider to see exactly where time is lost along the way, and as it turns out the scaling actually isn't responsible for the slow down, but instead the storing of the thumbnail in a database was. So, now I'm using a transaction and a timer to commit all the thumbnails to the database once they're all finished loading. Thus, now I'm down at ~50-80ms per thumbnail created, which is about as fast as it is in the QWidget version.
    (I'm going to stick with doing all that in C++, as I'm also doing some painting on the thumbnails using QPainter...)

    However:

    If you are doing scaling at C++ level then it is not worth it.
    I'm still confused why you think loading 2-4 images simultaneously on different CPU cores wouldn't give any benefits speedwise?

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

    Default Re: QML - load multiple Images simultaneously

    Quote Originally Posted by huilui View Post
    I'm still confused why you think loading 2-4 images simultaneously on different CPU cores wouldn't give any benefits speedwise?
    Because your GPU will do it about 100 (or more) times faster. I'm not saying you shouldn't do it anyway if you intend to stick with scaling in C++. But if you ever decide to do some animations or alike in QtQuick where you will want to scale the thumbnail up (e.g. to highlight it), you will lose quality.

    As far as painting on the image is concerned, you can still do it in QML using a custom item (derived from QQuickPaintedItem) keeping all the benefits of QML and QtQuick.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 6
    Last Post: 10th February 2014, 12:43
  2. Replies: 3
    Last Post: 11th December 2012, 20:48
  3. Replies: 1
    Last Post: 3rd January 2012, 21:15
  4. Painting in multiple QWidgets simultaneously
    By edepetete in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2011, 17:21
  5. Replies: 1
    Last Post: 16th November 2010, 17:45

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.