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. [SOLVED] Image problem loading
QtWS25 Last Chance

[SOLVED] Image problem loading

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 2 Posters 2.1k Views
  • 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
    maxvanceffer
    wrote on last edited by
    #1

    I have a strange behavior with Image source param

    I have XmlListModel wich source url is generated on the fly, depending on user choice

    @
    XmlListModel {
    id: movies_model
    query: '/api/users'

    onStatusChanged: { if( status === XmlListModel.Error ) console.log('Error ' + errorString()); }
    
    XmlRole{ name: "id"; query: "id/string()"}
    XmlRole{ name: "name"; query: "name/string()"}
    XmlRole{ name: "logo"; query: "logo/string()"} // absolute url to server image 
    

    }
    @

    and when source url generated

    in delegate of ListView :

    @
    Component {
    id: list_delegate

                    Image {
                        id: movie_logo
                        source: logo
                        height: 30;
                        width: 30;
                    }
    

    }

    ListView {
    delegate: list_delegate
    }
    @

    And when model is loaded image is empty and debug has message :

    MoviesListPage.qml:69:21: QML Image: Cannot open: file:///home/developer/projects/build-Patria-Desktop_Qt_5_1_1_GCC_32bit-Debug/qml/ProjectUsers/ http://localhost/app_dev.php/media/cache/thumbnail/images/users/527b7609df4c7.png

    Some how when image take role name logo data, it trying merge absolute path to the qml with data from xml

    Did somebody meet such problems ? Any help ?!

    1 Reply Last reply
    0
    • P Offline
      P Offline
      portoist
      wrote on last edited by
      #2

      Try it like this maybe?
      @
      Image {
      property url logoUrl: logo
      source: logoUrl
      height: 30;
      width: 30;
      }
      @

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

        Nope the same result (( It's strange, the debug shows that logo has only url. So it must work. But debug shows that image trying loading full path to qml + given url separted by space

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maxvanceffer
          wrote on last edited by
          #4

          Using Qt 5.1 release

          1 Reply Last reply
          0
          • P Offline
            P Offline
            portoist
            wrote on last edited by
            #5

            Well, how about this:
            @ Image{
            property string url: logo
            height: 30;
            width: 30;
            source: url.trim()
            }
            @
            Maybe that space is part of your url string and makes trouble.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maxvanceffer
              wrote on last edited by
              #6

              Meeeeeeeen thx... This must be in docs !!!

              It's working !! I didn't expected that the space brokes all.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                portoist
                wrote on last edited by
                #7

                Glad that it helped. I also wouldn't expect that space could brake it like this. I will try to add doc note to QML image.

                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