Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Image provider QImage requestImage() requestedSize is always -1
Qt 6.11 is out! See what's new in the release blog

Image provider QImage requestImage() requestedSize is always -1

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    moesul
    wrote on last edited by
    #1

    I’ve implemented an image provider (QImage requestImage ( const QString & id, QSize* size, const QSize& requestedSize))

    all works fine except that requestedSize is always -1, what did I do wrong?

    My code form the text.qml is as follows:
    @
    Image
    {
    id: img;
    x: 20;
    y: 20;
    width: 140;
    asynchronous: true;

       source: "image://thumbnailimage/Pictures/e1.jpg";
    }
    

    @

    1 Reply Last reply
    0
    • M Offline
      M Offline
      minimoog77
      wrote on last edited by
      #2

      If I understand docs clearly 'The requestedSize corresponds to the Image::sourceSize requested by an Image element. If requestedSize is a valid size, the image returned should be of that size' you should check that if requestedSize is a valid size you should return image by that size. If it's not valid then you should return image by her real size.

      In your case, you didn't set property requestedSize so requestedSize in image provider would be -1. You should return original size of the image.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        moesul
        wrote on last edited by
        #3

        That was it

        by setting the following properties in qml
        sourceSize.width: 120;
        sourceSize.height: 100;

        that in turns set the QSize requestedSize in my image provider.

        Thanks for your help

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved