Last active
April 4, 2018 03:52
-
-
Save stephenquan/142b2f60ab6b83e4b024f3a6de247573 to your computer and use it in GitHub Desktop.
qml-image-filedialog-sample.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This sample allows you to pick and view an image from your pictures folder | |
import QtQuick 2.7 | |
import QtQuick.Controls 2.1 | |
import QtQuick.Dialogs 1.2 | |
import QtQuick.Layouts 1.3 | |
Item { | |
ColumnLayout { | |
anchors.fill: parent | |
anchors.margins: 10 | |
RowLayout { | |
Layout.fillWidth: true | |
TextField { | |
id: textField | |
Layout.fillWidth: true | |
placeholderText: qsTr("Enter image's URL") | |
wrapMode: Text.WrapAtWordBoundaryOrAnywhere | |
} | |
Button { | |
text: "..." | |
onClicked: fileDialog.open() | |
} | |
} | |
Image { | |
id: image | |
Layout.fillWidth: true | |
Layout.fillHeight: true | |
source: textField.text | |
fillMode: Image.PreserveAspectFit | |
} | |
} | |
FileDialog { | |
id: fileDialog | |
folder: shortcuts.pictures | |
onAccepted: textField.text = fileDialog.fileUrl | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment