我刚刚开始在 Ubuntu 14.10 上使用基于 Qt5.2.1 的 QtCreator 3.1.1 为 Ubuntu 部署我的第一个应用程序。我需要打开一些视频文件,所以我要放置一个按钮来选择文件。我也知道我可以使用此功能打开文件:
FileDialog {
id: fileDialog
title: "Please choose a file"
onAccepted: {
console.log("You chose: " + fileDialog.fileUrls)
Qt.quit()
}
onRejected: {
console.log("Canceled")
Qt.quit()
}
Component.onCompleted: visible = true
}
这是我的问题:如何将它们相互连接?我希望在单击按钮时打开 FielDialog。这是唯一的方法吗?我的意思是我不能在 C++ 代码中做同样的过程吗?