QML - property url question
-
I'm playing around with QML, below is a simple component
@
Rectangle {
id: rectangle1
property string imageOn: "some filepath"
property string imageOff: "some filepath"
property string textMessage: "Submit"BorderImage { id: border_image1 visible: !mouse_area1.pressed anchors.fill: parent source: parent.imageOn } BorderImage { id: border_image2 anchors.fill: parent visible: mouse_area1.pressed source: parent.imageOff }
}
@Using QT Creator, If I drag this component and put it on another QML file in designer view the designer will show all the properties fine. I'd like the imageOn and imageOff properties to be set in the Designer by having the user choose a file, not by typing in a long file path. Is there anyway to do this?
Thanks
[EDIT: code formatting, please wrap in @-tags, Volker]
-
Try with
@
property url imageOn: "some filepath"
@Also as this is a separate component I think it's better to use
@
property alias imageOn: border_image1.source
@ -
When I set a property in a qml file like property url image: "some filepath" when I go in the designer it doesn't create a file dialog for the property. How can I set a property for a component that asks the user to choose from a file via the file dialog?
Maybe this is not possible yet, but the image component and the border image component has the user choose a file through a dialog box for the source.