Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkFileChooser Class Reference

Convenience widget showing a line edit with a file/directory path and a browse button. More...

#include <QmitkFileChooser.h>

Inheritance diagram for QmitkFileChooser:
Collaboration diagram for QmitkFileChooser:

Signals

void NewFileSelected (const std::string &filePath)
 Emitted when the file path changes, either programmatically or by the user. More...
 

Public Member Functions

 QmitkFileChooser (QWidget *parent=nullptr, Qt::WindowFlags f={})
 Construct the file chooser with default settings. More...
 
void SetHorizotalLayout (bool horizontalLayout)
 Set horizontal or vertical layout for the button and line edit. More...
 
void SetSelectDir (bool selectDir)
 Set whether the chooser selects directories instead of files. More...
 
void SetFileMustExist (bool fileMustExist)
 Set whether the selected file or directory must already exist. More...
 
void SetFile (const std::string &file)
 Programmatically set the file path. More...
 
void SetFilePattern (const std::string &filepattern)
 Set the file filter pattern for the file dialog. More...
 
void SetReadOnly (bool ReadOnly)
 Set whether the line edit is read-only. More...
 
bool IsValidFile () const
 Check whether the currently entered file/directory exists. More...
 
virtual std::string GetFile () const
 Get the currently displayed file path. More...
 

Protected Slots

virtual void OnSelectFileClicked (bool)
 
virtual void OnFileEditingFinished ()
 

Protected Attributes

bool m_SelectDir
 
bool m_FileMustExist
 
QString m_FilePattern
 
QPushButton * m_SelectFile
 
QLineEdit * m_File
 

Detailed Description

Convenience widget showing a line edit with a file/directory path and a browse button.

Provides a line edit displaying the current path and a "Select File" button that opens a QFileDialog. Various options control whether files or directories are selected, whether they must exist, and whether the line edit is editable.

Definition at line 29 of file QmitkFileChooser.h.

Constructor & Destructor Documentation

◆ QmitkFileChooser()

QmitkFileChooser::QmitkFileChooser ( QWidget *  parent = nullptr,
Qt::WindowFlags  f = {} 
)
explicit

Construct the file chooser with default settings.

Defaults: vertical layout, file mode (not directory), file must exist, read-only line edit.

Parameters
[in]parentThe parent widget.
[in]fWindow flags.

Member Function Documentation

◆ GetFile()

virtual std::string QmitkFileChooser::GetFile ( ) const
virtual

Get the currently displayed file path.

Returns
The absolute file path as a string.

◆ IsValidFile()

bool QmitkFileChooser::IsValidFile ( ) const

Check whether the currently entered file/directory exists.

Returns
True if the path exists on disk.

◆ NewFileSelected

void QmitkFileChooser::NewFileSelected ( const std::string &  filePath)
signal

Emitted when the file path changes, either programmatically or by the user.

Parameters
[in]filePathThe new file path.

◆ OnFileEditingFinished

virtual void QmitkFileChooser::OnFileEditingFinished ( )
protectedvirtualslot

check for valid here

◆ OnSelectFileClicked

virtual void QmitkFileChooser::OnSelectFileClicked ( bool  )
protectedvirtualslot

show dialog here

◆ SetFile()

void QmitkFileChooser::SetFile ( const std::string &  file)

Programmatically set the file path.

Parameters
[in]fileThe file or directory path to set.

If fileMustExist is true and the path does not exist, the path is not set.

◆ SetFileMustExist()

void QmitkFileChooser::SetFileMustExist ( bool  fileMustExist)

Set whether the selected file or directory must already exist.

Parameters
[in]fileMustExistTrue (default) to require existence, false to allow new paths.

◆ SetFilePattern()

void QmitkFileChooser::SetFilePattern ( const std::string &  filepattern)

Set the file filter pattern for the file dialog.

Parameters
[in]filepatternA Qt file filter string (e.g. "Images (*.png *.jpg)").

◆ SetHorizotalLayout()

void QmitkFileChooser::SetHorizotalLayout ( bool  horizontalLayout)

Set horizontal or vertical layout for the button and line edit.

Parameters
[in]horizontalLayoutIf true, button is placed to the right of the line edit. If false (default), button is below.

◆ SetReadOnly()

void QmitkFileChooser::SetReadOnly ( bool  ReadOnly)

Set whether the line edit is read-only.

Parameters
[in]ReadOnlyTrue to make read-only (default), false to allow manual editing.

◆ SetSelectDir()

void QmitkFileChooser::SetSelectDir ( bool  selectDir)

Set whether the chooser selects directories instead of files.

Parameters
[in]selectDirTrue for directory selection, false (default) for file selection.

Member Data Documentation

◆ m_File

QLineEdit* QmitkFileChooser::m_File
protected

the line edit to show the current file

Definition at line 133 of file QmitkFileChooser.h.

◆ m_FileMustExist

bool QmitkFileChooser::m_FileMustExist
protected
See also
SetFileMustExist()

Definition at line 120 of file QmitkFileChooser.h.

◆ m_FilePattern

QString QmitkFileChooser::m_FilePattern
protected
See also
SetFilePattern()

Definition at line 125 of file QmitkFileChooser.h.

◆ m_SelectDir

bool QmitkFileChooser::m_SelectDir
protected
See also
SetSelectDir()

Definition at line 116 of file QmitkFileChooser.h.

◆ m_SelectFile

QPushButton* QmitkFileChooser::m_SelectFile
protected

the select file button

Definition at line 129 of file QmitkFileChooser.h.


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