赞
踩
Qt中有一些内置的对话框dialog,比如
在QWidget工程中使用比较容易,比如
- #include <QFileDialog>
-
- fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), "/home/jana", tr("Image Files (*.png *.jpg *.bmp)"));
那么在QML工程中如何使用呢?如下代码为QML中的一个FileDialog 实现。
- import QtQuick 2.2
- import QtQuick.Dialogs 1.0
-
- FileDialog {
- id: fileDialog
- title: "Please choose a file"
- folder: shortcuts.home
- nameFilters: [ "Image files (*.jpg *.png)", "All files (*)" ]
- onAccepted: {
- console.log("You chose: " + fileDialog.fileUrls)
- Qt.quit()
- }
- onRejected: {
- console.log("Canceled")
- Qt.quit()
- }
- Component.onCompleted: visible = true
- }

FileDialog 的调用可以在一个butto
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。