Add Static Path to Image Source in qml



  • hi
    I need to add images to Image source statically from Project folder...
    @Image{
    id: imageCap
    anchors.centerIn: parent
    width: parent.width; height: parent.height; smooth: true
    fillMode: Image.PreserveAspectFit
    source: "file:///Images/Image1.png"
    }@

    Here ImageCapture is my project name and i have created Images folder in it and placed few images in it..I dont want to give relative path from my system and as well as i dont want to use qrc file..so that wen i build app i shud be able to load images in all other syatems also...so how do i do that..Can anyone help me on this issue...

    Thanks in Advance...



  • Try with this.

    source : Qt.resolvedUrl("file:///C:/Qt/Images/Image1.png")

    assuming that your files are in C:/Qt/Images directory



  • Hi
    I do not want to give absolute path..I want to give relative path from project folder...Absolute path works fine...Let me tel u my scenary...

    I want to buld app on desktop and run in on Android Os..so i need that relative path...please post ur reply if u knw that..
    thanks in Advance



  • I may not know the exact answer. Let me try.
    Your earlier post said that you don't want to give relative path. Hence absolute path came into picture.

    You can give relative path like the following.

    Image {
        source : "../images/ball.png"
     }
    

    I have kept binary and main.qml in <home>qt/bins directory. Images in <home>/qt/images while executing the program.

    Not sure why u don't want to use resource files.



  • Hi
    sorry that was a mistake from me while typing.I require nly relative path. And the above sample of code does not work for me..
    And the reason y i do not want to use qrc is,i will be capturing images from camera and will be saved in project folder during runtime...So i cant add that files to qrc at dynamic time right..so i chose this method..Do u think is there a better way to handle..?

    Thanks for ur Reply Dheerendra


Log in to reply
 

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