Class SBGWidgetFileSelector#
ClassList > SBGWidgetFileSelector
The SBGWidgetFileSelector class is a convenience widget for specifying a file path - it contains a label, a line edit, and a push button to browse for a file.More...
#include "SBGWidgetFileSelector.hpp"
Inherits the following classes: QWidget
Public Slots#
Type | Name |
---|---|
slot void | onBrowse |
Public Signals#
Type | Name |
---|---|
signal void | pathChanged |
Public Functions#
Type | Name |
---|---|
SBGWidgetFileSelector (QWidget * parent=nullptr) Constructs a path selector widget. |
|
QString | getDefaultDirectory () const Returns the default directory of the selector. |
QString | getFilePath () Returns the path. |
QString | getFilter () const Returns the filter of the selector. |
QString | getLabel () const Returns the label shown in the selector. |
void | setDefaultDirectory (const QString & dir) Sets the default directory for the selector that will be used for browse if the file path is not set. |
void | setFilePath (const QString & path) Sets the path. |
void | setFilter (const QString & filter) Sets the filter for the selector. |
void | setLabel (const QString & label) Sets the label shown in the selector. |
virtual | ~SBGWidgetFileSelector () Destructs the path selector widget. |
Public Static Functions#
Type | Name |
---|---|
bool | checkFile (const QString & path, bool askUser) Check whether the file exists. |
Detailed Description#
Short name: SBFileSelector
Public Slots Documentation#
slot onBrowse#
Public Signals Documentation#
signal pathChanged#
Public Functions Documentation#
function SBGWidgetFileSelector#
Constructs a path selector widget.
When the user clicks on the browse button of this widget, it internally invokes the SBGWindowDialog::getFileNameFromUser function.
The file dialog's working directory is set to the directory of the file path, if specified, else it is set to the default directory, if specified.
// create the file selector widget
SBFileSelector* fileSelector = new SBFileSelector();
fileSelector->setLabel("Choose input file");
// add the file selector widget into a layout
// ...
You can specify the filter in the same way it is specified in QFileDialog. Only files that match the given filter are shown.
You can provide a single filter, for example:
If you want multiple filters, separate them with ';;', for example:
See also: SAMSON::getFileNameFromUser, SAMSON::getFileNamesFromUser, SAMSON::getSaveFileNameFromUser
function getDefaultDirectory#
Returns the default directory of the selector.
function getFilePath#
Returns the path.
function getFilter#
Returns the filter of the selector.
function getLabel#
Returns the label shown in the selector.
function setDefaultDirectory#
Sets the default directory for the selector that will be used for browse if the file path is not set.
function setFilePath#
Sets the path.
function setFilter#
Sets the filter for the selector.
function setLabel#
Sets the label shown in the selector.
function ~SBGWidgetFileSelector#
Destructs the path selector widget.
Public Static Functions Documentation#
function checkFile#
Check whether the file exists.