Setting static path to image source
-
hi friends
I am trying to set static path to an image source which i was not able to overcome..I do not want an image to be used from qrc file...So i need to access an image from desktop in ubuntu qml qt..here i tried like
Image {
id: xxx
anchors.centerIn: parent.center
source: "file:///home/xx......../image1.jpg"
or
source: "/home/xx......../image1.jpg"
}i could not load that image and i am trying hard to get..it will be greta if some one can help me with this..
Thanks in Advance friends...
-
Hi,
I don't see any problem in source of Image element. Use "file:///" as prefix to path.
Are you sure that the image path is correct ?
Any error printed to the console ? -
Can you post the complete code ? Please use Code tags "@@" while posting.
-
Hi
Here is the code posted ..sory i was not knowing how to use code tags@
ListView {id : list anchors { left: parent.left; top: shutterButton.bottom; right: parent.right; bottom: parent.bottom} spacing: 3 orientation: ListView.Horizontal model: 10 delegate: Rectangle { anchors { verticalCenter: parent.verticalCenter } width: 70; height: 70; color: "grey"; border.color: "#000"; radius: 5 Image { id: imagecap anchors { centerIn: parent } visible: true source: "file:///home/bala/Desktop/Image1.jpg" } } }
@
-
Alright Question, Is this the only code in your QML ? It seems you have not given width and height to ListView. Please try again with proper width and height for ListView.
I'm assuming now that the file path is absolutly correct. -
Well i tried this and it worked for me
@
ListView {
id : list
width: 200
height: 300
spacing: 3
model: 10
orientation: ListView.Horizontal
delegate: Rectangle {
anchors { verticalCenter: parent.verticalCenter }
width: 70; height: 70;
color: "grey";
border.color: "#000";
radius: 5
Image {
id: imagecap
anchors { centerIn: parent }
source: "file:///home/user1/Pictures/star.jpg"
}
}
}
@ -
On Android it must be a different path.
-
Hi
Actual code is i am capturing an image and saving that image in one path using "camera" class .I found where the image is saved using "camera.imageCapture.capturedimagepath()" ..path is like "/storage "/sdcard0/DCIM/******etc /img.png"..i assigned the path to listview image source. i deployed the application on android phone and found the path ,bt it is not retrieving in image source in listview...this is exactly my requirement..Thanks for guiding...:-)
-
And does it work if you assign some other already existing image ?
any errors in Qt Creator's console when you run the application on phone ?
Is the image that you captured a valid image ? you can try opening it in default image viewer on phone -
yeah i have included images through qrc file but nt static paths...in my phone it does not printt anything on console window...yeah image is an valid one and i am able to open and see in phone..
image saved in phone at: "/storage/sdcard0/DCIM/Pictures/IMG_00001.jpg"
the same path i have given as source to image as
"file:///storage/sdcard0/DCIM/Pictures/IMG_00001.jpg" -
Is the image accessible outside Rectangle ? You can try to use Image element directly instead of placing inside the Rectangle. But i don't think so that would be a problem.