Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwidgetplatformfiledialog.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6
7#include <QtWidgets/qfiledialog.h>
8
10
12 : m_dialog(new QFileDialog)
13{
15
18
19 connect(m_dialog.data(), &QFileDialog::fileSelected, this, [this](const QString &file) {
20 emit fileSelected(QUrl::fromLocalFile(file));
21 });
22 connect(m_dialog.data(), &QFileDialog::filesSelected, this, [this](const QList<QString> &files) {
23 QList<QUrl> urls;
24 urls.reserve(files.size());
25 for (const QString &file : files)
26 urls += QUrl::fromLocalFile(file);
27 emit filesSelected(urls);
28 });
29 connect(m_dialog.data(), &QFileDialog::currentChanged, this, [this](const QString &path) {
30 emit currentChanged(QUrl::fromLocalFile(path));
31 });
34}
35
39
41{
42 return false; // TODO: ?
43}
44
49
51{
52 return m_dialog->directoryUrl();
53}
54
56{
57 m_dialog->selectUrl(filename);
58}
59
61{
62 return m_dialog->selectedUrls();
63}
64
66{
67 // TODO: ?
68}
69
74
79
81{
82 m_dialog->exec();
83}
84
101
103{
104 m_dialog->hide();
105}
106
108
109#include "moc_qwidgetplatformfiledialog_p.cpp"
void rejected()
virtual int exec()
Shows the dialog as a \l{QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it.
Definition qdialog.cpp:543
void accepted()
bool isLabelExplicitlySet(DialogLabel label)
QString labelText(DialogLabel label) const
AcceptMode acceptMode() const
QStringList nameFilters() const
FileDialogOptions options() const
The QFileDialog class provides a dialog that allows users to select files or directories.
Definition qfiledialog.h:28
FileMode
This enum is used to indicate what the user may select in the file dialog; that is,...
Definition qfiledialog.h:40
void currentChanged(const QString &path)
When the current file changes for local operations, this signal is emitted with the new file name as ...
QString selectedNameFilter() const
void setDefaultSuffix(const QString &suffix)
void filesSelected(const QStringList &files)
When the selection changes for local operations and the dialog is accepted, this signal is emitted wi...
void setNameFilters(const QStringList &filters)
QUrl directoryUrl() const
Returns the url of the directory currently being displayed in the dialog.
void fileSelected(const QString &file)
When the selection changes for local operations and the dialog is accepted, this signal is emitted wi...
void filterSelected(const QString &filter)
void setAcceptMode(AcceptMode mode)
void selectNameFilter(const QString &filter)
@ DontUseNativeDialog
Definition qfiledialog.h:52
void setDirectory(const QString &directory)
Sets the file dialog's current directory.
void selectUrl(const QUrl &url)
Selects the given url in the file dialog.
void setFileMode(FileMode mode)
AcceptMode
\value AcceptOpen \value AcceptSave
Definition qfiledialog.h:42
void setLabelText(DialogLabel label, const QString &text)
Sets the text shown in the filedialog in the specified label.
QList< QUrl > selectedUrls() const
Returns a list of urls containing the selected files in the dialog.
void setOptions(Options options)
void directoryEntered(const QString &directory)
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
void setParent(QObject *parent)
Makes the object a child of parent.
Definition qobject.cpp:2195
virtual void exec()=0
virtual void hide()=0
virtual bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)=0
virtual void selectNameFilter(const QString &filter)=0
virtual void setFilter()=0
virtual QUrl directory() const =0
virtual QString selectedNameFilter() const =0
virtual void setDirectory(const QUrl &directory)=0
virtual void selectFile(const QUrl &filename)=0
void directoryEntered(const QUrl &directory)
void filterSelected(const QString &filter)
virtual bool defaultNameFilterDisables() const =0
const QSharedPointer< QFileDialogOptions > & options() const
virtual QList< QUrl > selectedFiles() const =0
T * data() const noexcept
Returns the value of the pointer referenced by this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition qurl.cpp:3425
static bool show(QDialog *dialog, Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
QWidgetPlatformFileDialog(QObject *parent=nullptr)
void hide()
Hides the widget.
Definition qwidget.cpp:8135
void setWindowTitle(const QString &)
Definition qwidget.cpp:6105
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
WindowModality
GLbitfield flags
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLsizei const GLchar *const * path
QFile file
[0]
QStringList files
[8]