QGIS API Documentation  2.99.0-Master (01468d0)
Public Types | Signals | Public Member Functions | Static Public Member Functions | Properties | Friends | List of all members
QgsFileWidget Class Reference

The QgsFileWidget class creates a widget for selecting a file or a folder. More...

#include <qgsfilewidget.h>

Inheritance diagram for QgsFileWidget:
Inheritance graph
[legend]

Public Types

enum  RelativeStorage { Absolute, RelativeProject, RelativeDefaultPath }
 The RelativeStorage enum determines if path is absolute, relative to the current project path or relative to a defined default path. More...
 
enum  StorageMode { GetFile, GetDirectory, GetMultipleFiles }
 The StorageMode enum determines if the file picker should pick files or directories. More...
 

Signals

void fileChanged (const QString &)
 emitted as soon as the current file or directory is changed More...
 

Public Member Functions

 QgsFileWidget (QWidget *parent=nullptr)
 QgsFileWidget creates a widget for selecting a file or a folder. More...
 
QString defaultRoot () const
 returns the default root path More...
 
QString dialogTitle () const
 returns the open file dialog title More...
 
QString filePath ()
 Returns the current file path(s) when multiple files are selected, they are quoted and separated by a single space (for example: '"/path/foo" "path/bar"') More...
 
bool fileWidgetButtonVisible () const
 determines if the tool button is shown More...
 
QString filter () const
 returns the filters used for QDialog::getOpenFileName More...
 
bool fullUrl () const
 returns if the links shows the full path or not More...
 
QLineEdit * lineEdit ()
 Returns a pointer to the widget's line edit, which can be used to customize the appearance and behavior of the line edit portion of the widget. More...
 
QgsFileWidget::RelativeStorage relativeStorage () const
 returns if the relative path is with respect to the project path or the default path More...
 
void setDefaultRoot (const QString &defaultRoot)
 determines the default root path used as the first shown location when picking a file and used if the RelativeStorage is RelativeDefaultPath More...
 
void setDialogTitle (const QString &title)
 setDialogTitle defines the open file dialog title More...
 
void setFilePath (QString path)
 Sets the file path. More...
 
void setFileWidgetButtonVisible (bool visible)
 determines if the tool button is shown More...
 
void setFilter (const QString &filter)
 setFilter sets the filter used by the model to filters. More...
 
void setFullUrl (bool fullUrl)
 determines if the links shows the full path or not More...
 
void setReadOnly (bool readOnly)
 defines if the widget is readonly More...
 
void setRelativeStorage (QgsFileWidget::RelativeStorage relativeStorage)
 determines if the relative path is with respect to the project path or the default path More...
 
void setStorageMode (QgsFileWidget::StorageMode storageMode)
 determines the storage mode (i.e. file or directory) More...
 
void setUseLink (bool useLink)
 determines if the file path will be shown as a link More...
 
QgsFileWidget::StorageMode storageMode () const
 returns the storage mode (i.e. file or directory) More...
 
bool useLink () const
 determines if the file path will be shown as a link More...
 

Static Public Member Functions

static QStringList splitFilePaths (const QString &path)
 Split the the quoted and space separated path and returns a QString list. More...
 

Properties

QString defaultRoot
 
QString dialogTitle
 
bool fileWidgetButtonVisible
 
QString filter
 
bool fullUrl
 
RelativeStorage relativeStorage
 
StorageMode storageMode
 
bool useLink
 

Friends

class TestQgsFileWidget
 

Detailed Description

The QgsFileWidget class creates a widget for selecting a file or a folder.

Definition at line 34 of file qgsfilewidget.h.

Member Enumeration Documentation

◆ RelativeStorage

The RelativeStorage enum determines if path is absolute, relative to the current project path or relative to a defined default path.

Enumerator
Absolute 
RelativeProject 
RelativeDefaultPath 

Definition at line 72 of file qgsfilewidget.h.

◆ StorageMode

The StorageMode enum determines if the file picker should pick files or directories.

Enumerator
GetFile 
GetDirectory 

Select a single file.

GetMultipleFiles 

Select a directory.

Definition at line 62 of file qgsfilewidget.h.

Constructor & Destructor Documentation

◆ QgsFileWidget()

QgsFileWidget::QgsFileWidget ( QWidget *  parent = nullptr)
explicit

QgsFileWidget creates a widget for selecting a file or a folder.

Definition at line 33 of file qgsfilewidget.cpp.

Member Function Documentation

◆ defaultRoot()

QString QgsFileWidget::defaultRoot ( ) const

returns the default root path

◆ dialogTitle()

QString QgsFileWidget::dialogTitle ( ) const

returns the open file dialog title

◆ fileChanged

void QgsFileWidget::fileChanged ( const QString &  )
signal

emitted as soon as the current file or directory is changed

◆ filePath()

QString QgsFileWidget::filePath ( )

Returns the current file path(s) when multiple files are selected, they are quoted and separated by a single space (for example: '"/path/foo" "path/bar"')

See also
filePaths

Definition at line 75 of file qgsfilewidget.cpp.

◆ fileWidgetButtonVisible()

bool QgsFileWidget::fileWidgetButtonVisible ( ) const

determines if the tool button is shown

◆ filter()

QString QgsFileWidget::filter ( ) const

returns the filters used for QDialog::getOpenFileName

◆ fullUrl()

bool QgsFileWidget::fullUrl ( ) const

returns if the links shows the full path or not

◆ lineEdit()

QLineEdit * QgsFileWidget::lineEdit ( )

Returns a pointer to the widget's line edit, which can be used to customize the appearance and behavior of the line edit portion of the widget.

Since
QGIS 3.0

Definition at line 222 of file qgsfilewidget.cpp.

◆ relativeStorage()

QgsFileWidget::RelativeStorage QgsFileWidget::relativeStorage ( ) const

returns if the relative path is with respect to the project path or the default path

◆ setDefaultRoot()

void QgsFileWidget::setDefaultRoot ( const QString &  defaultRoot)

determines the default root path used as the first shown location when picking a file and used if the RelativeStorage is RelativeDefaultPath

Definition at line 196 of file qgsfilewidget.cpp.

◆ setDialogTitle()

void QgsFileWidget::setDialogTitle ( const QString &  title)

setDialogTitle defines the open file dialog title

Note
if not defined, the title is "Select a file" or "Select a directory" or "Select one or more files" depending on the configuration.

Definition at line 116 of file qgsfilewidget.cpp.

◆ setFilePath()

void QgsFileWidget::setFilePath ( QString  path)

Sets the file path.

Definition at line 93 of file qgsfilewidget.cpp.

◆ setFileWidgetButtonVisible()

void QgsFileWidget::setFileWidgetButtonVisible ( bool  visible)

determines if the tool button is shown

Definition at line 137 of file qgsfilewidget.cpp.

◆ setFilter()

void QgsFileWidget::setFilter ( const QString &  filter)

setFilter sets the filter used by the model to filters.

The filter is used to specify the kind of files that should be shown.

Parameters
filterOnly files that match the given filter are shown, it may be an empty string. If you want multiple filters, separate them with ';;',

Definition at line 126 of file qgsfilewidget.cpp.

◆ setFullUrl()

void QgsFileWidget::setFullUrl ( bool  fullUrl)

determines if the links shows the full path or not

Definition at line 186 of file qgsfilewidget.cpp.

◆ setReadOnly()

void QgsFileWidget::setReadOnly ( bool  readOnly)

defines if the widget is readonly

Definition at line 105 of file qgsfilewidget.cpp.

◆ setRelativeStorage()

void QgsFileWidget::setRelativeStorage ( QgsFileWidget::RelativeStorage  relativeStorage)

determines if the relative path is with respect to the project path or the default path

Definition at line 217 of file qgsfilewidget.cpp.

◆ setStorageMode()

void QgsFileWidget::setStorageMode ( QgsFileWidget::StorageMode  storageMode)

determines the storage mode (i.e. file or directory)

Definition at line 206 of file qgsfilewidget.cpp.

◆ setUseLink()

void QgsFileWidget::setUseLink ( bool  useLink)

determines if the file path will be shown as a link

Definition at line 164 of file qgsfilewidget.cpp.

◆ splitFilePaths()

QStringList QgsFileWidget::splitFilePaths ( const QString &  path)
static

Split the the quoted and space separated path and returns a QString list.

See also
filePath

Definition at line 80 of file qgsfilewidget.cpp.

◆ storageMode()

QgsFileWidget::StorageMode QgsFileWidget::storageMode ( ) const

returns the storage mode (i.e. file or directory)

◆ useLink()

bool QgsFileWidget::useLink ( ) const

determines if the file path will be shown as a link

Friends And Related Function Documentation

◆ TestQgsFileWidget

friend class TestQgsFileWidget
friend

Definition at line 189 of file qgsfilewidget.h.

Property Documentation

◆ defaultRoot

QString QgsFileWidget::defaultRoot
readwrite

Definition at line 53 of file qgsfilewidget.h.

◆ dialogTitle

QString QgsFileWidget::dialogTitle
readwrite

Definition at line 51 of file qgsfilewidget.h.

◆ fileWidgetButtonVisible

bool QgsFileWidget::fileWidgetButtonVisible
readwrite

Definition at line 48 of file qgsfilewidget.h.

◆ filter

QString QgsFileWidget::filter
readwrite

Definition at line 52 of file qgsfilewidget.h.

◆ fullUrl

bool QgsFileWidget::fullUrl
readwrite

Definition at line 50 of file qgsfilewidget.h.

◆ relativeStorage

QgsFileWidget::RelativeStorage QgsFileWidget::relativeStorage
readwrite

Definition at line 55 of file qgsfilewidget.h.

◆ storageMode

QgsFileWidget::StorageMode QgsFileWidget::storageMode
readwrite

Definition at line 54 of file qgsfilewidget.h.

◆ useLink

bool QgsFileWidget::useLink
readwrite

Definition at line 49 of file qgsfilewidget.h.


The documentation for this class was generated from the following files: