I've just started to deploy my first application for Ubuntu using QtCreator 3.1.1 based on Qt5.2.1 on Ubuntu 14.10.. I need to open some video files, so I'm going to put a Button to choose file obviously. Also I know I can use this function to open files:
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
}
Here's my question: How can I connect them to each other? I want the FielDialog to be opened when I click on the button. And is that the only way to do this? I mean couldn't I do the same process in C++ code?
Of course you can do in C++. There's a Qt class called QFileDialog: http://qt-project.org/doc/qt-5/QFileDialog.html You can simply connect a button clicked signal to a slot that creates a QFileDialog, you can use some of the static functions like in the example:
and here how to use the QPushButton: http://qt-project.org/wiki/How_to_Use_QPushButton