[SOLVED] Image problem loading



  • 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 ?!



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



  • 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



  • Using Qt 5.1 release



  • 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.



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

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



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.