Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [SOLVED] Image problem loading

    QML and Qt Quick
    2
    7
    1813
    Loading More Posts
    • 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
      maxvanceffer last edited by

      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 Reply Quote 0
      • P
        portoist last edited by

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

        1 Reply Last reply Reply Quote 0
        • M
          maxvanceffer last edited by

          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 Reply Quote 0
          • M
            maxvanceffer last edited by

            Using Qt 5.1 release

            1 Reply Last reply Reply Quote 0
            • P
              portoist last edited by

              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 Reply Quote 0
              • M
                maxvanceffer last edited by

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

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

                1 Reply Last reply Reply Quote 0
                • P
                  portoist last edited by

                  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 Reply Quote 0
                  • First post
                    Last post