Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkFileChooser.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef QmitkFileChooser_h
14 #define QmitkFileChooser_h
15 
17 #include <QWidget>
18 
19 class QPushButton;
20 class QLineEdit;
21 
30 {
31  Q_OBJECT
32 
33 public:
42  explicit QmitkFileChooser(QWidget *parent = nullptr, Qt::WindowFlags f = {});
43 
49  void SetHorizotalLayout(bool horizontalLayout);
50 
55  void SetSelectDir(bool selectDir);
56 
61  void SetFileMustExist(bool fileMustExist);
62 
69  void SetFile(const std::string &file);
70 
75  void SetFilePattern(const std::string &filepattern);
76 
81  void SetReadOnly(bool ReadOnly);
82 
87  bool IsValidFile() const;
88 
93  virtual std::string GetFile() const;
94 
95 signals:
100  void NewFileSelected(const std::string &filePath);
101 
102 protected slots:
106  virtual void OnSelectFileClicked(bool /*checked=false*/);
110  virtual void OnFileEditingFinished();
111 
112 protected:
121 
125  QString m_FilePattern;
129  QPushButton *m_SelectFile;
133  QLineEdit *m_File;
134 };
135 
136 #endif
#define MITKQTWIDGETSEXT_EXPORT
Convenience widget showing a line edit with a file/directory path and a browse button.
void SetHorizotalLayout(bool horizontalLayout)
Set horizontal or vertical layout for the button and line edit.
virtual std::string GetFile() const
Get the currently displayed file path.
void SetSelectDir(bool selectDir)
Set whether the chooser selects directories instead of files.
QmitkFileChooser(QWidget *parent=nullptr, Qt::WindowFlags f={})
Construct the file chooser with default settings.
virtual void OnFileEditingFinished()
virtual void OnSelectFileClicked(bool)
void SetFilePattern(const std::string &filepattern)
Set the file filter pattern for the file dialog.
void NewFileSelected(const std::string &filePath)
Emitted when the file path changes, either programmatically or by the user.
void SetFile(const std::string &file)
Programmatically set the file path.
bool IsValidFile() const
Check whether the currently entered file/directory exists.
void SetReadOnly(bool ReadOnly)
Set whether the line edit is read-only.
void SetFileMustExist(bool fileMustExist)
Set whether the selected file or directory must already exist.
QPushButton * m_SelectFile