Skip to content

Instantly share code, notes, and snippets.

@stephenquan
Last active March 4, 2018 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenquan/0ee658375c933740d127e8ebe45a1170 to your computer and use it in GitHub Desktop.
Save stephenquan/0ee658375c933740d127e8ebe45a1170 to your computer and use it in GitHub Desktop.
AppStudio copy and open and embedded resource
// This sample demonstrates how to copy out a resource from your app to your file system.
//
// This AppStudio works around the issue that you cannot give the operating system links
// to resources embedded in your application. To achieve this, we copy the resources out
// which causes their URL to change from a qrc:/ to file:/ URI. After copying, we can
// easily open the file with Qt.openUrlExternally.
import QtQuick 2.7
import QtQuick.Controls 2.1
import ArcGIS.AppFramework 1.0
App {
id: app
width: 400 * AppFramework.displayScaleFactor
height: 640 * AppFramework.displayScaleFactor
Button {
text: qsTr("Copy and Open")
onClicked: {
dest.removeFile("readme.txt");
dest.copyFile(source.filePath("sample.txt"), dest.filePath("sample.txt"))
Qt.openUrlExternally(dest.fileUrl("sample.txt"));
}
}
FileFolder {
id: source
url: "."
}
FileFolder {
id: dest
path: "~"
}
}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment