#ifndef FileDialog_H#define FileDialog_H#include <QFileDialog>#include <QtDeclarative>namespace viewer{ class FileDialog : public QDeclarativeItem { Q_OBJECT Q_PROPERTY(QString fileExtension READ getFileExtension WRITE setFileExtension NOTIFY fileExtensionChanged) Q_PROPERTY(QString name READ name WRITE setName) public: FileDialog(); QString _fileDialog; QString name() const; void setName(const QString &name); QString getFileExtension(); void setFileExtension(QString v); signals: void fileExtensionChanged(); };}QML_DECLARE_TYPE(viewer::FileDialog)#endif // FileDialog_H
#include "viewer/fileDialog.h"namespace viewer{ FileDialog::FileDialog() { } QString FileDialog::getFileExtension(){ return _fileDialog; } void FileDialog::setFileExtension(QString v){ _fileDialog = v; emit fileExtensionChanged(); } QString FileDialog::name() const{ return "111sdd" ; } void FileDialog::setName(const QString &name){ }}
FileDialog{ id: bg // fileExtension: ".mp3" //name: "fsdfsdfsdf"; }
QDeclarativeComponent: Component is not ready
FileDialog { id: fileDialogLoad folder: "." title: "Choose a file to open" selectMultiple: false nameFilters: [ "Image files (*.png *.jpg)", "All files (*)" ] onAccepted: { console.log("Accepted: " + filePaths) } }
Button{ text: "выбрать файл" onClicked: fileDialogLoad.open(); }
FileDialog{ }
FileDialog { id: fileDialogLoad folder: "." title: "Choose a file to open" selectMultiple: false nameFilters: [ "Music files (*.mp3 *.wav)"] onAccepted: { buttonFileDialog.visible = false; var mas = new Array(); mas = filePath.split("/"); fileNameMusic.text = mas[mas.length-1]; fileDialogLoad.close(); } onRejected: fileDialogLoad.close(); }
modality: Qt.WindowModality