CopperSpice API  1.9.1
QFileDialog Class Reference

Provides a dialog which allow the selection of files or directories. More...

Inheritance diagram for QFileDialog:
QDialog QWidget QObject QPaintDevice

Public Typedefs

using FileDialogOptions = QFlags< FileDialogOption >
 
- Public Typedefs inherited from QWidget
using RenderFlags = QFlags< RenderFlag >
 

Public Types

enum  AcceptMode
 
enum  DialogLabel
 
enum  FileDialogOption
 
enum  FileMode
 
enum  ViewMode
 
- Public Types inherited from QDialog
enum  DialogCode
 
- Public Types inherited from QWidget
enum  RenderFlag
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric
 

Public Signals

void currentChanged (const QString &path)
 
void currentUrlChanged (const QUrl &url)
 
void directoryEntered (const QString &directory)
 
void directoryUrlEntered (const QUrl &directory)
 
void fileSelected (const QString &file)
 
void filesSelected (const QStringList &files)
 
void filterSelected (const QString &filter)
 
void urlSelected (const QUrl &url)
 
void urlsSelected (const QList< QUrl > &urls)
 
- Public Signals inherited from QDialog
void accepted ()
 
void finished (int result)
 
void rejected ()
 
- Public Signals inherited from QWidget
void customContextMenuRequested (const QPoint &pos)
 
void windowIconChanged (const QIcon &icon)
 
void windowIconTextChanged (const QString &iconText)
 
void windowTitleChanged (const QString &title)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

virtual void open ()
 
- Public Slots inherited from QDialog
virtual void accept ()
 
virtual void done (int result)
 
virtual int exec ()
 
virtual void open ()
 
virtual void reject ()
 
void showExtension (bool showExt)
 
- Public Slots inherited from QWidget
bool close ()
 
void hide ()
 
void lower ()
 
void raise ()
 
void repaint ()
 
void setDisabled (bool disable)
 
void setEnabled (bool enable)
 
void setFocus ()
 
void setHidden (bool hidden)
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool modified)
 
void setWindowTitle (const QString &title)
 
void show ()
 
void showFullScreen ()
 
void showMaximized ()
 
void showMinimized ()
 
void showNormal ()
 
void update ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QFileDialog (QWidget *parent, Qt::WindowFlags flags)
 
 QFileDialog (QWidget *parent=nullptr, const QString &caption=QString (), const QString &directory=QString (), const QString &filter=QString ())
 
 ~QFileDialog ()
 
AcceptMode acceptMode () const
 
bool confirmOverwrite () const
 
QString defaultSuffix () const
 
QDir directory () const
 
QUrl directoryUrl () const
 
FileMode fileMode () const
 
QDir::Filters filter () const
 
QStringList history () const
 
QFileIconProvidericonProvider () const
 
bool isNameFilterDetailsVisible () const
 
bool isReadOnly () const
 
QAbstractItemDelegateitemDelegate () const
 
QString labelText (DialogLabel label) const
 
QStringList mimeTypeFilters () const
 
QStringList nameFilters () const
 
void open (QObject *receiver, const QString &member)
 
FileDialogOptions options () const
 
QAbstractProxyModelproxyModel () const
 
bool resolveSymlinks () const
 
bool restoreState (const QByteArray &state)
 
QByteArray saveState () const
 
QStringList selectedFiles () const
 
QString selectedNameFilter () const
 
QList< QUrlselectedUrls () const
 
void selectFile (const QString &filename)
 
void selectMimeTypeFilter (const QString &filter)
 
void selectNameFilter (const QString &filter)
 
void selectUrl (const QUrl &url)
 
void setAcceptMode (AcceptMode mode)
 
void setConfirmOverwrite (bool enabled)
 
void setDefaultSuffix (const QString &suffix)
 
void setDirectory (const QDir &directory)
 
void setDirectory (const QString &directory)
 
void setDirectoryUrl (const QUrl &directory)
 
void setFileMode (FileMode mode)
 
void setFilter (QDir::Filters filters)
 
void setHistory (const QStringList &paths)
 
void setIconProvider (QFileIconProvider *provider)
 
void setItemDelegate (QAbstractItemDelegate *delegate)
 
void setLabelText (DialogLabel label, const QString &text)
 
void setMimeTypeFilters (const QStringList &filters)
 
void setNameFilter (const QString &filter)
 
void setNameFilterDetailsVisible (bool enabled)
 
void setNameFilters (const QStringList &filters)
 
void setOption (FileDialogOption option, bool on=true)
 
void setOptions (FileDialogOptions options)
 
void setProxyModel (QAbstractProxyModel *model)
 
void setReadOnly (bool enabled)
 
void setResolveSymlinks (bool enabled)
 
void setSidebarUrls (const QList< QUrl > &urls)
 
void setSupportedSchemes (const QStringList &schemes)
 
void setViewMode (ViewMode mode)
 
void setVisible (bool visible) override
 
QList< QUrlsidebarUrls () const
 
QStringList supportedSchemes () const
 
bool testOption (FileDialogOption option) const
 
ViewMode viewMode () const
 
- Public Methods inherited from QDialog
 QDialog (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
 ~QDialog ()
 
QWidgetextension () const
 
bool isSizeGripEnabled () const
 
QSize minimumSizeHint () const override
 
Qt::Orientation orientation () const
 
int result () const
 
void setExtension (QWidget *extension)
 
void setModal (bool modal)
 
void setOrientation (Qt::Orientation orientation)
 
void setResult (int result)
 
void setSizeGripEnabled (bool enabled)
 
void setVisible (bool visible) override
 
QSize sizeHint () const override
 
- Public Methods inherited from QWidget
 QWidget (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
 ~QWidget ()
 
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 
void activateWindow ()
 
void addAction (QAction *action)
 
void addActions (const QList< QAction * > &actions)
 
void adjustSize ()
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 
QBackingStorebackingStore () const
 
QSize baseSize () const
 
QWidget * childAt (const QPoint &position) const
 
QWidget * childAt (int x, int y) const
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 
void clearMask ()
 
QMargins contentsMargins () const
 
QRect contentsRect () const
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
QCursor cursor () const
 
WId effectiveWinId () const
 
void ensurePolished () const
 
Qt::FocusPolicy focusPolicy () const
 
QWidget * focusProxy () const
 
QWidget * focusWidget () const
 
const QFontfont () const
 
QFontInfo fontInfo () const
 
QFontMetrics fontMetrics () const
 
QPalette::ColorRole foregroundRole () const
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 
QPixmap grab (const QRect &rectangle=QRect (QPoint (0, 0), QSize (-1,-1)))
 
void grabGesture (Qt::GestureType gestureType, Qt::GestureFlags flags=Qt::GestureFlags ())
 
void grabKeyboard ()
 
void grabMouse ()
 
void grabMouse (const QCursor &cursor)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 
QGraphicsEffectgraphicsEffect () const
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 
bool hasEditFocus () const
 
bool hasFocus () const
 
virtual bool hasHeightForWidth () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int width) const
 
Qt::InputMethodHints inputMethodHints () const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
void insertAction (QAction *before, QAction *action)
 
void insertActions (QAction *before, QList< QAction * > actions)
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 
bool isEnabled () const
 
bool isEnabledTo (const QWidget *parent) const
 
bool isEnabledToTLW () const
 
bool isFullScreen () const
 
bool isHidden () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isTopLevel () const
 
bool isVisible () const
 
bool isVisibleTo (const QWidget *parent) const
 
bool isWindow () const
 
bool isWindowModified () const
 
QLayoutlayout () const
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
QPoint mapFrom (const QWidget *parent, const QPoint &pos) const
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapFromParent (const QPoint &pos) const
 
QPoint mapTo (const QWidget *parent, const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QPoint mapToParent (const QPoint &pos) const
 
QRegion mask () const
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
int minimumWidth () const
 
void move (const QPoint &point)
 
void move (int x, int y)
 
QWidget * nativeParentWidget () const
 
QWidget * nextInFocusChain () const
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags flags)
 
QPaintEnginepaintEngine () const override
 
const QPalettepalette () const
 
QWidget * parentWidget () const
 
QPoint pos () const
 
QWidget * previousInFocusChain () const
 
QRect rect () const
 
void releaseKeyboard ()
 
void releaseMouse ()
 
void releaseShortcut (int id)
 
void removeAction (QAction *action)
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren))
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren))
 
void repaint (const QRect &rect)
 
void repaint (const QRegion &region)
 
void repaint (int x, int y, int w, int h)
 
void resize (const QSize &size)
 
void resize (int w, int h)
 
bool restoreGeometry (const QByteArray &geometry)
 
QByteArray saveGeometry () const
 
void scroll (int dx, int dy)
 
void scroll (int dx, int dy, const QRect &rect)
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute attribute, bool enable=true)
 
void setAutoFillBackground (bool enable)
 
void setBackgroundRole (QPalette::ColorRole role)
 
void setBaseSize (const QSize &size)
 
void setBaseSize (int basew, int baseh)
 
void setContentsMargins (const QMargins &margins)
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &cursor)
 
void setEditFocus (bool enable)
 
void setFixedHeight (int h)
 
void setFixedSize (const QSize &size)
 
void setFixedSize (int w, int h)
 
void setFixedWidth (int w)
 
void setFocus (Qt::FocusReason reason)
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *widget)
 
void setFont (const QFont &font)
 
void setForegroundRole (QPalette::ColorRole role)
 
void setGeometry (const QRect &rect)
 
void setGeometry (int x, int y, int w, int h)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *layout)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &bitmap)
 
void setMask (const QRegion &region)
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &size)
 
void setMaximumSize (int maxw, int maxh)
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &size)
 
void setMinimumSize (int minw, int minh)
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &palette)
 
void setParent (QWidget *parent)
 
void setParent (QWidget *parent, Qt::WindowFlags flags)
 
void setShortcutAutoRepeat (int id, bool enable=true)
 
void setShortcutEnabled (int id, bool enable=true)
 
void setSizeIncrement (const QSize &size)
 
void setSizeIncrement (int w, int h)
 
void setSizePolicy (QSizePolicy policy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
void setStatusTip (const QString &data)
 
void setStyle (QStyle *style)
 
void setToolTip (const QString &data)
 
void setToolTipDuration (int msec)
 
void setUpdatesEnabled (bool enable)
 
void setWhatsThis (const QString &str)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags flags)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &role)
 
void setWindowState (Qt::WindowStates windowState)
 
QSize size () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *widget)
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute attribute) const
 
QString toolTip () const
 
int toolTipDuration () const
 
QWidget * topLevelWidget () const
 
bool underMouse () const
 
void ungrabGesture (Qt::GestureType gestureType)
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (const QRect &rect)
 
void update (const QRegion &region)
 
void update (int x, int y, int w, int h)
 
void updateGeometry ()
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 
QString whatsThis () const
 
int width () const
 
QWidget * window () const
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 
QWindowwindowHandle () const
 
QIcon windowIcon () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 
Qt::WindowStates windowState () const
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 
WId winId () const
 
int x () const
 
int y () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 
- Public Methods inherited from QPaintDevice
virtual ~QPaintDevice ()
 
int colorCount () const
 
int depth () const
 
int devicePixelRatio () const
 
qreal devicePixelRatioF () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 

Static Public Methods

static QString getExistingDirectory (QWidget *parent=nullptr, const QString &caption=QString (), const QString &dir=QString (), FileDialogOptions options=ShowDirsOnly)
 
static QUrl getExistingDirectoryUrl (QWidget *parent=nullptr, const QString &caption=QString (), const QUrl &dir=QUrl (), FileDialogOptions options=ShowDirsOnly, const QStringList &supportedSchemes=QStringList ())
 
static QString getOpenFileName (QWidget *parent=nullptr, const QString &caption=QString (), const QString &dir=QString (), const QString &filter=QString (), QString *selectedFilter=nullptr, FileDialogOptions options=FileDialogOptions ())
 
static QStringList getOpenFileNames (QWidget *parent=nullptr, const QString &caption=QString (), const QString &dir=QString (), const QString &filter=QString (), QString *selectedFilter=nullptr, FileDialogOptions options=FileDialogOptions ())
 
static QUrl getOpenFileUrl (QWidget *parent=nullptr, const QString &caption=QString (), const QUrl &dir=QUrl (), const QString &filter=QString (), QString *selectedFilter=nullptr, FileDialogOptions options=FileDialogOptions (), const QStringList &supportedSchemes=QStringList ())
 
static QList< QUrlgetOpenFileUrls (QWidget *parent=nullptr, const QString &caption=QString (), const QUrl &dir=QUrl (), const QString &filter=QString (), QString *selectedFilter=nullptr, FileDialogOptions options=FileDialogOptions (), const QStringList &supportedSchemes=QStringList ())
 
static QString getSaveFileName (QWidget *parent=nullptr, const QString &caption=QString (), const QString &dir=QString (), const QString &filter=QString (), QString *selectedFilter=nullptr, FileDialogOptions options=FileDialogOptions ())
 
static QUrl getSaveFileUrl (QWidget *parent=nullptr, const QString &caption=QString (), const QUrl &dir=QUrl (), const QString &filter=QString (), QString *selectedFilter=nullptr, FileDialogOptions options=FileDialogOptions (), const QStringList &supportedSchemes=QStringList ())
 
- Static Public Methods inherited from QWidget
static QWidget * createWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
static QWidget * find (WId id)
 
static QWidget * keyboardGrabber ()
 
static QWidget * mouseGrabber ()
 
static void setTabOrder (QWidget *firstWidget, QWidget *secondWidget)
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 

Protected Methods

void accept () override
 
void changeEvent (QEvent *event) override
 
void done (int result) override
 
- Protected Methods inherited from QDialog
void closeEvent (QCloseEvent *event) override
 
void contextMenuEvent (QContextMenuEvent *event) override
 
bool eventFilter (QObject *object, QEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 
void showEvent (QShowEvent *event) override
 
- Protected Methods inherited from QWidget
virtual void actionEvent (QActionEvent *event)
 
void create (WId window=0, bool initializeWindow=true, bool destroyOldWindow=true)
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 
virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
virtual void enterEvent (QEvent *event)
 
bool event (QEvent *event) override
 
virtual void focusInEvent (QFocusEvent *event)
 
bool focusNextChild ()
 
virtual bool focusNextPrevChild (bool next)
 
virtual void focusOutEvent (QFocusEvent *event)
 
bool focusPreviousChild ()
 
virtual void hideEvent (QHideEvent *event)
 
void initPainter (QPainter *painter) const override
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void leaveEvent (QEvent *event)
 
int metric (PaintDeviceMetric metric) const override
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void moveEvent (QMoveEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, long *result)
 
virtual void paintEvent (QPaintEvent *event)
 
virtual void tabletEvent (QTabletEvent *event)
 
virtual void wheelEvent (QWheelEvent *event)
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Methods inherited from QPaintDevice
 QPaintDevice ()
 

Properties

 acceptMode
 
 confirmOverwrite
 
 defaultSuffix
 
 fileMode
 
 nameFilterDetailsVisible
 
 options
 
 readOnly
 
 resolveSymlinks
 
 supportedSchemes
 
 viewMode
 
- Properties inherited from QDialog
 modal
 
 sizeGripEnabled
 
- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 toolTip
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 

Friends

class QPlatformDialogHelper
 

Additional Inherited Members

- Protected Slots inherited from QWidget
void updateMicroFocus ()
 

Detailed Description

The QFileDialog class provides a dialog which allows the selection of files or directories. It is generally easier to create a QFileDialog using the static methods. On Windows, OS X, KDE, and GNOME, these static methods will call the native file dialog when possible.

Example One

In the following example a modal dialog is created using a static method. The dialog will initially display the contents of the "/home/frank" directory and every file which matches the given filter. The parent of the file dialog will be this, the title is "Open Image", and the filter is "Image Files (*.png *.jpg *.bmp)".

fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), "/home/frank", tr("Image Files (*.png *.jpg *.bmp)"));

To use multiple filters separate each one with two semicolons as shown below.

"Images (*.png *.jpg *.bmp);;Text files (*.txt);;XML files (*.xml)"

Example Two

This example shows how to create a QFileDialog without using the static methods. The call to setFileMode() is used to specify what type of file or directory the user may select.

  • The mode of QFileDialog::AnyFile means the user can select any file, or even specify a file that does not exist. This mode is useful for creating a "Save As" file dialog.
  • Using a mode of QFileDialog::ExistingFile the user must select an existing file.
  • The mode of QFileDialog::Directory only allows a directory to be selected.

Use the setNameFilter() method to set the filter of what files will be displayed.

There are two different view modes.

  • List mode presents the contents of the current directory as a list of file and directory names.
  • Detail mode displays a list of file and directory names and also provides additional information such as the file size and modification date.
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setNameFilter(tr("Images (*.png *.xpm *.jpg)"));
dialog.setViewMode(QFileDialog::Detail);

The last method you will need when creating your own file dialog is selectedFiles(). When the user selects a file and then clicks OK, the file name is assigned to the variable fileNames.

QStringList fileNames;
if (dialog.exec()) {
fileNames = dialog.selectedFiles();
}
See also
QDir, QFileInfo, QFile, QPrintDialog, QColorDialog, QFontDialog

Member Typedef Documentation

Member Enumeration Documentation

ConstantValue
QFileDialog::AcceptOpen0
QFileDialog::AcceptSave1
ConstantValue
QFileDialog::LookIn0
QFileDialog::FileName1
QFileDialog::FileType2
QFileDialog::Accept3
QFileDialog::Reject4

This enum indicates various settings for how the file dialog should be displayed.

ConstantValueDescription
QFileDialog::ShowDirsOnly 0x00000001 Only show directories in the file dialog. By default both files and directories are shown. (Valid only in the Directory file mode.)
QFileDialog::DontResolveSymlinks 0x00000002 Do not resolve symlinks in the file dialog. By default symlinks are resolved.
QFileDialog::DontConfirmOverwrite 0x00000004 Do not ask for confirmation if an existing file is selected. By default confirmation is requested.
QFileDialog::DontUseSheet 0x00000008 The static functions will always be an application modal dialog. If you want to use sheets, use QFileDialog::open() instead.
QFileDialog::DontUseNativeDialog 0x00000010 Do not use the native file dialog. By default, the native file dialog is used unless you use a subclass of QFileDialog that contains the CS_OBJECT macro, or the platform does not have a native dialog of the type that you require.
QFileDialog::ReadOnly 0x00000020 Indicates that the model is readonly.
QFileDialog::HideNameFilterDetails 0x00000040 Indicates if the file name filter details are hidden or not.
QFileDialog::ForceInitialDir_Win7 0x00000080 Force Windows 7 to honor initial path
QFileDialog::DontUseCustomDirectoryIcons 0x00000100 Always use the default directory icon. Some platforms allow the user to set a different icon. Custom icon lookup cause a big performance impact over network or removable drives. Setting this will enable the QFileIconProvider::DontUseCustomDirectoryIcons option in the icon provider.

This enum is used to indicate what the user may select in the file dialog. For example, what the dialog will return if the user clicks OK.

ConstantValueDescription
QFileDialog::AnyFile0 The name of a file whether it exists or not.
QFileDialog::ExistingFile1 The name of a single existing file.
QFileDialog::Directory2 The name of a directory. Both files and directories are displayed.
QFileDialog::ExistingFiles3 The names of zero or more existing files.

The following value is obsolete.

ConstantValueDescription
QFileDialog::DirectoryOnly4 Use Directory and setOption(ShowDirsOnly, true) instead.
See also
setFileMode()

This enum describes the view mode of the file dialog; for example what information about each file will be displayed.

ConstantValueDescription
QFileDialog::Detail0Displays an icon, a name, and details for each item in the directory.
QFileDialog::List1Displays only an icon and a name for each item in the directory.
See also
setViewMode()

Constructor & Destructor Documentation

QFileDialog::QFileDialog ( QWidget parent,
Qt::WindowFlags  flags 
)
deprecated

Constructs a file dialog with the given parent and flags.

QFileDialog::QFileDialog ( QWidget parent = nullptr,
const QString caption = QString(),
const QString directory = QString(),
const QString filter = QString() 
)
explicit

Constructs a file dialog with the given parent and caption that initially displays the contents of the specified directory. The contents of the directory are filtered before being shown in the dialog, using a semicolon-separated list of filters specified by filter.

QFileDialog::~QFileDialog ( )

Destroys the file dialog.

Method Documentation

void QFileDialog::accept ( )
overrideprotected

Reimplemented from QDialog::accept()

AcceptMode QFileDialog::acceptMode ( ) const

Returns the value of the property.

void QFileDialog::changeEvent ( QEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::changeEvent()

bool QFileDialog::confirmOverwrite ( ) const

Returns the value of the property.

void QFileDialog::currentChanged ( const QString path)
signal

When the current file changes this signal is emitted with the new file name as the path parameter.

See also
filesSelected()
void QFileDialog::currentUrlChanged ( const QUrl url)
signal

When the current file changes this signal is emitted with the new file URL as the url parameter.

See also
urlsSelected()
QString QFileDialog::defaultSuffix ( ) const

Returns the value of the property.

QDir QFileDialog::directory ( ) const

Returns the directory currently being displayed in the dialog.

See also
setDirectory()
void QFileDialog::directoryEntered ( const QString directory)
signal

This signal is emitted when the user enters a directory.

QUrl QFileDialog::directoryUrl ( ) const

Returns the url of the directory currently being displayed in the dialog.

See also
setDirectoryUrl()
void QFileDialog::directoryUrlEntered ( const QUrl directory)
signal

This signal is emitted when the user enters a directory.

void QFileDialog::done ( int  result)
overrideprotected

Reimplemented from QDialog::done()

FileMode QFileDialog::fileMode ( ) const

Returns the value of the property.

void QFileDialog::fileSelected ( const QString file)
signal

When the selection changes and the dialog is accepted this signal is emitted with the (possibly empty) selected file.

See also
currentChanged(), QDialog::DialogCode
void QFileDialog::filesSelected ( const QStringList files)
signal

When the selection changes and the dialog is accepted this signal is emitted with the (possibly empty) list of files.

See also
currentChanged(), QDialog::DialogCode
QDir::Filters QFileDialog::filter ( ) const

Returns the filter that is used when displaying files.

See also
setFilter()
void QFileDialog::filterSelected ( const QString filter)
signal

This signal is emitted when the user selects a filter.

QString QFileDialog::getExistingDirectory ( QWidget parent = nullptr,
const QString caption = QString(),
const QString dir = QString(),
FileDialogOptions  options = ShowDirsOnly 
)
static

This is a convenience method which will return an existing directory selected by the user.

QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
"/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);

This method creates a modal file dialog with the given parent. If parent is not a nullptr, the dialog will be shown centered over the parent widget. The dialog's working directory is set to dir, and the title is set to caption. Either of these may be an empty string in which case the current directory and a default caption will be used.

The options argument holds various options about how to run the dialog. Refer to the FileDialogOption enum for more information on the flags which can be passed. To ensure a native file dialog, ShowDirsOnly must be set.

On Windows and Mac OS X this static method will use a native file dialog and not one created by this class. On Windows the dialog will run a blocking modal event loop that will not dispatch any QTimers, and if parent is not a nullptr then it will position the dialog just below the parent's title bar.

On Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If options includes DontResolveSymlinks, the file dialog will treat symlinks as regular directories.

Warning
Do not delete parent during the execution of the dialog. If you want to do this, create the dialog using one of the QFileDialog constructors.
See also
getOpenFileName(), getOpenFileNames(), getSaveFileName()
QUrl QFileDialog::getExistingDirectoryUrl ( QWidget parent = nullptr,
const QString caption = QString(),
const QUrl dir = QUrl(),
FileDialogOptions  options = ShowDirsOnly,
const QStringList supportedSchemes = QStringList() 
)
static

This is a convenience method which will return an existing directory selected by the user. If the user presses Cancel an empty url is returned.

The method is used similarly to QFileDialog::getExistingDirectory(). In particular parent, caption, dir and options are used in the exact same way. The main difference between this method and QFileDialog::getExistingDirectory(), is this method allows the user to select a remote directory.

The supportedSchemes argument allows to restrict the type of URLs the user will be able to select. It is a way for the application to declare the protocols it will support to fetch the file content. An empty list means that no restriction is applied (the default). Supported for local files ("file" scheme) is implicit and always enabled. it is not necessary to include in the restriction.

When possible this method will use a native file dialog and not one created by this class. On platforms which do not support selecting remote files this method will allow the user to select only local files.

See also
getExistingDirectory(), getOpenFileUrl(), getOpenFileUrls(), getSaveFileUrl()
QString QFileDialog::getOpenFileName ( QWidget parent = nullptr,
const QString caption = QString(),
const QString dir = QString(),
const QString filter = QString(),
QString selectedFilter = nullptr,
FileDialogOptions  options = FileDialogOptions() 
)
static

This is a convenience method which returns an existing file selected by the user. If the user presses Cancel an empty string is returned.

QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "/home", tr("Images (*.png *.xpm *.jpg)"));

The method creates a modal file dialog with the given parent. If parent is not a nullptr, the dialog will be shown centered over the parent widget.

The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. Only files that match the given filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter, and filter may be empty strings. If you want multiple filters separate them with ';;'.

"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"

The options argument holds various options about how to run the dialog. Refer to the FileDialogOption enum for more information on the flags which can be passed. The dialog's title is set to caption. If caption is not specified then a default caption will be used.

On Windows and Mac OS X this static method will use a native file dialog and not one created by this class. On Windows the dialog will run a blocking modal event loop that will not dispatch any QTimers, and if parent is not a nullptr then it will position the dialog just below the parent's title bar.

On Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If options includes DontResolveSymlinks, the file dialog will treat symlinks as regular directories.

Warning
Do not delete parent during the execution of the dialog. If you want to do this, create the dialog using one of the QFileDialog constructors.
See also
getOpenFileNames(), getSaveFileName(), getExistingDirectory()
QStringList QFileDialog::getOpenFileNames ( QWidget parent = nullptr,
const QString caption = QString(),
const QString dir = QString(),
const QString filter = QString(),
QString selectedFilter = nullptr,
FileDialogOptions  options = FileDialogOptions() 
)
static

This is a convenience method which returns one or more existing files selected by the user.

QStringList files = QFileDialog::getOpenFileNames(this, "Select one or more files to open", "/home",
"Images (*.png *.xpm *.jpg)");

This method creates a modal file dialog with the given parent. If parent is not a nullptr the dialog will be shown centered over the parent widget.

The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. The filter is set to filter so that only those files which match the filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter, and filter may be empty strings. If you need multiple filters separate them with ';;'.

"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"

The dialog's title is set to caption. If caption is not specified then a default caption will be used.

On Windows and Mac OS X this static method will use a native file dialog and not created by this class. On Windows the dialog will run a blocking modal event loop that will not dispatch any QTimers, and if parent is not a nullptr then it will position the dialog just below the parent's title bar.

On Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. The options argument holds various options about how to run the dialog, see the QFileDialog::Option enum for more information on the flags you can pass.

Warning
Do not delete parent during the execution of the dialog. If you want to do this, create the dialog using one of the QFileDialog constructors.
See also
getOpenFileName(), getSaveFileName(), getExistingDirectory()
QUrl QFileDialog::getOpenFileUrl ( QWidget parent = nullptr,
const QString caption = QString(),
const QUrl dir = QUrl(),
const QString filter = QString(),
QString selectedFilter = nullptr,
FileDialogOptions  options = FileDialogOptions(),
const QStringList supportedSchemes = QStringList() 
)
static

This is a convenience method which returns an existing file selected by the user. If the user presses Cancel an empty url is returned.

The method is used similarly to QFileDialog::getOpenFileName(). The values for parent, caption, dir, filter, selectedFilter, and options are used in the exact same way. The main difference between this method and QFileDialog::getOpenFileName(), is this method allows the user to select a remote file.

The supportedSchemes argument allows to restrict the type of URLs the user will be able to select. It is a way for the application to declare the protocols it will support to fetch the file content. An empty list means that no restriction is applied (the default). Supported for local files ("file" scheme) is implicit and always enabled, it is not necessary to include it in the restriction.

When possible this method will use the native file dialog and not a QFileDialog. On platforms which do not support selecting remote files the user will only be allowed to select local files.

QList< QUrl > QFileDialog::getOpenFileUrls ( QWidget parent = nullptr,
const QString caption = QString(),
const QUrl dir = QUrl(),
const QString filter = QString(),
QString selectedFilter = nullptr,
FileDialogOptions  options = FileDialogOptions(),
const QStringList supportedSchemes = QStringList() 
)
static

This is a convenience method which will return one or more existing files selected by the user. If the user presses Cancel an empty list is returned.

The method is used similarly to QFileDialog::getOpenFileNames(). In values for parent, caption, dir, filter, selectedFilter, and options are used in the exact same way. The main difference between this method and QFileDialog::getOpenFileName(), is this method allows the user to select a remote file.

The supportedSchemes argument allows to restrict the type of URLs the user will be able to select. It is a way for the application to declare the protocols it will support to fetch the file content. An empty list means that no restriction is applied (the default). Supported for local files ("file" scheme) is implicit and always enabled; it is not necessary to include it in the restriction.

When possible this static method will use the native file dialog and not a QFileDialog. On platforms which do not support selecting remote files the user will only be allowed to select local files.

QString QFileDialog::getSaveFileName ( QWidget parent = nullptr,
const QString caption = QString(),
const QString dir = QString(),
const QString filter = QString(),
QString selectedFilter = nullptr,
FileDialogOptions  options = FileDialogOptions() 
)
static

This is a convenience method which will return a file selected by the user. The file does not have to exist.

It creates a modal file dialog with the given parent. If parent is not a nullptr the dialog will be shown centered over the parent widget.

QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
"/home/frank/untitled.png", tr("Images (*.png *.xpm *.jpg)"));

The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. Only files that match the filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter, and filter may be empty strings. Multiple filters are separated with ';;'.

"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"

The options argument holds various options about how to display the dialog. Refer to the FileDialogOption enum for more information on the flags which can be passed. The default filter can be chosen by setting selectedFilter to the desired value. The dialog's caption is set to caption. If caption is not specified a default caption will be used.

On Windows and OS X this static method will use a native file dialog and not one created by this class. On Windows the dialog will run a blocking modal event loop that will not dispatch any QTimers, and if parent is not a nullptr then it will position the dialog just below the parent's title bar. On Mac OS X with its native file dialog, the filter argument is ignored.

On Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If options includes DontResolveSymlinks the file dialog will treat symlinks as regular directories.

Warning
Do not delete parent during the execution of the dialog. If you want to do this create the dialog using one of the QFileDialog constructors.
See also
getOpenFileName(), getOpenFileNames(), getExistingDirectory()
QUrl QFileDialog::getSaveFileUrl ( QWidget parent = nullptr,
const QString caption = QString(),
const QUrl dir = QUrl(),
const QString filter = QString(),
QString selectedFilter = nullptr,
FileDialogOptions  options = FileDialogOptions(),
const QStringList supportedSchemes = QStringList() 
)
static

This is a convenience method which returns a file selected by the user. The file does not have to exist. If the user presses Cancel an empty url is returned.

The method is used similarly to QFileDialog::getSaveFileName(). The values for parent, caption, dir, filter, selectedFilter and options are used in the exact same way. The main difference between this method and QFileDialog::getSaveFileName(), is this method allows the user to select a remote file.

The supportedSchemes argument allows to restrict the type of URLs the user will be able to select. It is a way for the application to declare the protocols it will support to save the file content. An empty list means that no restriction is applied (the default). Supported for local files ("file" scheme) is implicit and always enabled. it is not necessary to include in the restriction.

When possible this method will use a native file dialog and not one created by this class. On platforms which do not support selecting remote files this method will allow the user to select only local files.

See also
getSaveFileName(), getOpenFileUrl(), getOpenFileUrls(), getExistingDirectoryUrl()
QStringList QFileDialog::history ( ) const

Returns the browsing history of the QFileDialog as a list of paths.

See also
setHistory()
QFileIconProvider * QFileDialog::iconProvider ( ) const

Returns the icon provider used by the QFileDialog.

See also
setIconProvider()
bool QFileDialog::isNameFilterDetailsVisible ( ) const

Returns the value of the property.

bool QFileDialog::isReadOnly ( ) const

Returns the value of the property.

QAbstractItemDelegate * QFileDialog::itemDelegate ( ) const

Returns the item delegate used to render the items in the views in the QFileDialog.

See also
setItemDelegate()
QString QFileDialog::labelText ( DialogLabel  label) const

Returns the text shown in the QFileDialog in the specified label.

See also
setLabelText()
QStringList QFileDialog::mimeTypeFilters ( ) const

Returns the MIME type filters that are in operation on this QFileDialog.

See also
setMimeTypeFilters()
QStringList QFileDialog::nameFilters ( ) const

Returns the file type filters that are in operation on this QFileDialog.

See also
setNameFilters()
void QDialog::open ( )
usingslot

Shows the dialog as a window modal dialog, returning immediately.

See also
exec(), show(), result(), setWindowModality()
void QFileDialog::open ( QObject receiver,
const QString member 
)

This method connects one of its signals to the slot specified by receiver and member. The specific signal depends is filesSelected() if fileMode is ExistingFiles and fileSelected() if fileMode is anything else.

The signal will be disconnected from the slot when the dialog is closed.

FileDialogOptions QFileDialog::options ( ) const

Returns the value of the property.

QAbstractProxyModel * QFileDialog::proxyModel ( ) const

Returns the proxy model used by the file dialog. By default no proxy is set.

See also
setProxyModel()
bool QFileDialog::resolveSymlinks ( ) const

Returns the value of the property.

bool QFileDialog::restoreState ( const QByteArray state)

Restores the dialog's layout, history and current directory to the state specified. Typically this is used in conjunction with QSettings to restore the size from a past session.

Returns false if there are errors

QByteArray QFileDialog::saveState ( ) const

Saves the state of the dialog's layout, history and current directory. Typically this is used in conjunction with QSettings to remember the size for a future session. A version number is stored as part of the data.

QStringList QFileDialog::selectedFiles ( ) const

Returns a list of strings containing the absolute paths of the selected files in the dialog. If no files are selected, or the mode is not ExistingFiles or ExistingFile, selectedFiles() contains the current path in the viewport.

See also
selectedNameFilter(), selectFile()
QString QFileDialog::selectedNameFilter ( ) const

Returns the filter that the user selected in the file dialog.

See also
selectedFiles()
QList< QUrl > QFileDialog::selectedUrls ( ) const

Returns a list of urls containing the selected files in the dialog. If no files are selected, or the mode is not ExistingFiles or ExistingFile, selectedUrls() contains the current path in the viewport.

See also
selectedNameFilter(), selectUrl()
void QFileDialog::selectFile ( const QString filename)

Selects the given filename in the file dialog.

See also
selectedFiles()
void QFileDialog::selectMimeTypeFilter ( const QString filter)

Sets the current MIME type to filter.

void QFileDialog::selectNameFilter ( const QString filter)

Sets the current file type filter. Multiple filters can be passed in filter by separating them with semicolons or spaces.

See also
setNameFilter(), setNameFilters(), selectedNameFilter()
void QFileDialog::selectUrl ( const QUrl url)

Selects the given url in the file dialog.

See also
selectedUrls()
void QFileDialog::setAcceptMode ( AcceptMode  mode)

Sets the value of the property to mode.

void QFileDialog::setConfirmOverwrite ( bool  enabled)

Sets the value of the property to enabled.

void QFileDialog::setDefaultSuffix ( const QString suffix)

Sets the value of the property to suffix.

void QFileDialog::setDirectory ( const QDir directory)
inline

Sets the file dialog's current directory to directory.

void QFileDialog::setDirectory ( const QString directory)

Sets the file dialog's current directory to directory.

void QFileDialog::setDirectoryUrl ( const QUrl directory)

Sets the file dialog's current directory to directory.

For Windows it is possible to pass URLs representing one of the virtual folders, such as "Computer" or "Network". This is done by passing a QUrl using the scheme clsid followed by the CLSID value with the curly braces removed. For example the URL clsid:374DE290-123F-4565-9164-39C4925E467B denotes the download location. For a complete list of possible values, see the MSDN documentation on KNOWNFOLDERID.

See also
directoryUrl(), QUuid
void QFileDialog::setFileMode ( FileMode  mode)

This method will set the labels for the FileName and Accept DialogLabels based on the given mode. It is possible to set custom text after the call to defilement().

void QFileDialog::setFilter ( QDir::Filters  filters)

Sets the filter used by the model to filters. The filter is used to specify the kind of files which are displayed.

See also
filter()
void QFileDialog::setHistory ( const QStringList paths)

Sets the browsing history of the QFileDialog to contain the given paths.

See also
history()
void QFileDialog::setIconProvider ( QFileIconProvider provider)

Sets the icon provider used by the QFileDialog to the specified provider.

See also
iconProvider()
void QFileDialog::setItemDelegate ( QAbstractItemDelegate delegate)

The item delegate is used when displaying file names and directories. It is set to the given delegate.

Delegate are used in conjunction with a model. For QFileDialog the model is the QFileSystemModel which has custom data roles specific to files.

Refer to QFileIconProvider if you only want custom icons.

Warning
You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the closeEditor() signal, and attempt to access, modify or close an editor that has already been closed.
See also
itemDelegate(), setIconProvider(), QFileSystemModel
void QFileDialog::setLabelText ( DialogLabel  label,
const QString text 
)

Sets the text shown in the QFileDialog for the specified label.

See also
labelText()
void QFileDialog::setMimeTypeFilters ( const QStringList filters)

This is a convenience method for setNameFilters().

Sets the filters used in the file dialog from a list of MIME types. Uses QMimeType to create a name filter from the glob patterns and description defined in each MIME type. Use application/octet-stream for the "All files (*)" filter, since that is the base MIME type for all files.

Calling setMimeTypeFilters overrides any previously set name filters, and changes the return value of nameFilters().

mimeTypeFilters << "image/jpeg" // will show "JPEG image (*.jpeg *.jpg *.jpe)
<< "image/png" // will show "PNG image (*.png)"
<< "application/octet-stream"; // will show "All files (*)"
QFileDialog dialog(this);
dialog.setMimeTypeFilters(mimeTypeFilters);
dialog.exec();
See also
mimeTypeFilters()
void QFileDialog::setNameFilter ( const QString filter)

Sets the filter used in the file dialog to the given filter. If filter contains a pair of parentheses containing one or more of anything*something, separated by spaces, then only the text contained in the parentheses is used as the filter. This means the follow calls are equivalent.

dialog.setNameFilter("All C++ files (*.cpp *.cc *.C *.cxx *.c++)");
dialog.setNameFilter("*.cpp *.cc *.C *.cxx *.c++");
See also
setNameFilters()
void QFileDialog::setNameFilterDetailsVisible ( bool  enabled)

Sets the value of the property to enables.

void QFileDialog::setNameFilters ( const QStringList filters)

Sets the filters used in the file dialog.

QStringList filters;
filters << "Image files (*.png *.xpm *.jpg)"
<< "Text files (*.txt)"
<< "Any files (*)";
QFileDialog dialog(this);
dialog.setNameFilters(filters);
dialog.exec();
See also
nameFilters()
void QFileDialog::setOption ( FileDialogOption  option,
bool  on = true 
)

Sets the given option to be enabled if on is true, otherwise clears the given option.

See also
options, testOption()
void QFileDialog::setOptions ( FileDialogOptions  options)

Sets the value of the property to options.

void QFileDialog::setProxyModel ( QAbstractProxyModel model)

Sets the model for the views to the given model. This is useful if you want to modify the underlying model. For example, to add columns, filter data, or add drives. Any existing proxy model will be removed, but not deleted. The file dialog will take ownership of the proxyModel.

See also
proxyModel()
void QFileDialog::setReadOnly ( bool  enabled)

Sets the value of the property to enabled.

void QFileDialog::setResolveSymlinks ( bool  enabled)

Sets the value of the property to enabled.

void QFileDialog::setSidebarUrls ( const QList< QUrl > &  urls)

Sets the urls that are located in the sidebar.

urls << QUrl::fromLocalFile("/home/fred/dev/music")
<< QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
QFileDialog dialog;
dialog.setSidebarUrls(urls);
dialog.setFileMode(QFileDialog::AnyFile);
if(dialog.exec()) {
// do something here
}

The file dialog will then look like this:

See also
sidebarUrls()
void QFileDialog::setSupportedSchemes ( const QStringList schemes)

Sets the value of the property to schemes.

void QFileDialog::setViewMode ( ViewMode  mode)

Sets the value of the property to mode.

void QFileDialog::setVisible ( bool  visible)
override

Sets the value of the property to visible.

QList< QUrl > QFileDialog::sidebarUrls ( ) const

Returns a list of urls that are currently in the sidebar.

See also
setSidebarUrls()
QStringList QFileDialog::supportedSchemes ( ) const

Returns the value of the property.

bool QFileDialog::testOption ( FileDialogOption  option) const

Returns true if the given option is enabled, otherwise returns false.

See also
options, setOption()
void QFileDialog::urlSelected ( const QUrl url)
signal

When the selection changes and the dialog is accepted, this signal is emitted with the (possibly empty) selected url.

See also
currentUrlChanged(), QDialog::DialogCode
void QFileDialog::urlsSelected ( const QList< QUrl > &  urls)
signal

When the selection changes and the dialog is accepted, this signal is emitted with the (possibly empty) list of selected urls.

See also
currentUrlChanged(), QDialog::DialogCode
ViewMode QFileDialog::viewMode ( ) const

Returns the value of the property.

Property Documentation

QFileDialog::acceptMode

This property holds the accept mode of the dialog. The action mode defines whether the dialog is for opening or saving files. By default, this property is set to AcceptOpen.

See also
AcceptMode
PropertiesClass Methods
read acceptMode
write setAcceptMode
QFileDialog::confirmOverwrite
deprecated
Deprecated:
This property holds whether the filedialog should ask before accepting a selected file, when the accept mode is AcceptSave.

Use setOption(DontConfirmOverwrite, !enabled) or !testOption(DontConfirmOverwrite) instead.

PropertiesClass Methods
read confirmOverwrite
write setConfirmOverwrite
designable true
QFileDialog::defaultSuffix

This property holds the suffix added to the filename if no other suffix was specified.

This property specifies a string that will be added to the filename if it has no suffix already. The suffix is typically used to indicate the file type. For example "txt" indicates a text file.

If the first character is a dot ('.'), it is removed.

PropertiesClass Methods
read defaultSuffix
write setDefaultSuffix
QFileDialog::fileMode

This property holds the file mode of the dialog.

The file mode defines the number and type of items that the user is expected to select in the dialog. By default, this property is set to AnyFile.

See also
FileMode
PropertiesClass Methods
read fileMode
write setFileMode
QFileDialog::nameFilterDetailsVisible
deprecated
Deprecated:
This property holds this property holds whether the filter details is shown or not.

When this property is true (the default), the filter details are shown in the combo box. When the property is set to false, these are hidden.

Use setOption(HideNameFilterDetails, !enabled) or !testOption(HideNameFilterDetails).

PropertiesClass Methods
read isNameFilterDetailsVisible
write setNameFilterDetailsVisible
designable true
QFileDialog::options

This property holds the various options that affect the look and feel of the dialog. By default, all options are disabled.

Options should be set before showing the dialog. Setting them while the dialog is visible is not guaranteed to have an immediate effect on the dialog (depending on the option and on the platform).

See also
setOption(), testOption()
PropertiesClass Methods
read options
write setOptions
QFileDialog::readOnly
deprecated
Deprecated:
This property holds whether the filedialog is read-only.

If this property is set to false, the file dialog will allow renaming, and deleting of files and directories and creating directories.

Use setOption(ReadOnly, enabled) or testOption(ReadOnly) instead.

PropertiesClass Methods
read isReadOnly
write setReadOnly
designable true
QFileDialog::resolveSymlinks
deprecated
Deprecated:
This property holds whether the filedialog should resolve shortcuts.

If this property is set to true, the file dialog will resolve shortcuts or symbolic links.

Use setOption(DontResolveSymlinks, !enabled) or !testOption(DontResolveSymlinks).

PropertiesClass Methods
read resolveSymlinks
write setResolveSymlinks
designable true
QFileDialog::supportedSchemes

This property holds the URL schemes that the file dialog should allow navigating to.

Setting this property allows to restrict the type of URLs the user will be able to select. It is a way for the application to declare the protocols it will support to fetch the file content. An empty list means that no restriction is applied (the default). Supported for local files ("file" scheme) is implicit and always enabled; it is not necessary to include it in the restriction.

PropertiesClass Methods
read supportedSchemes
write setSupportedSchemes
QFileDialog::viewMode

This property holds the way files and directories are displayed in the dialog. By default, the Detail mode is used to display information about files and directories.

See also
ViewMode
PropertiesClass Methods
read viewMode
write setViewMode