Qt Utilities  5.8.1
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
pathselection.h
Go to the documentation of this file.
1 #ifndef WIDGETS_PATHSELECTION_H
2 #define WIDGETS_PATHSELECTION_H
3 
4 #include "../global.h"
5 
6 #include <QFileDialog>
7 
8 QT_FORWARD_DECLARE_CLASS(QPushButton)
9 QT_FORWARD_DECLARE_CLASS(QCompleter)
10 
11 namespace Widgets {
12 
13 class ClearLineEdit;
14 
15 class QT_UTILITIES_EXPORT PathSelection : public QWidget {
16  Q_OBJECT
17 public:
18  explicit PathSelection(QWidget *parent = nullptr);
19 
20  ClearLineEdit *lineEdit();
21  const ClearLineEdit *lineEdit() const;
22  void provideCustomFileMode(QFileDialog::FileMode customFileMode);
23  void provideCustomFileDialog(QFileDialog *customFileDialog);
24 
25 protected:
26  bool eventFilter(QObject *obj, QEvent *event);
27 
28 private slots:
29  void showFileDialog();
30 
31 private:
32  ClearLineEdit *m_lineEdit;
33  QPushButton *m_button;
34  QFileDialog::FileMode m_customMode;
35  QFileDialog *m_customDialog;
36  static QCompleter *m_completer;
37 };
38 
43 {
44  return m_lineEdit;
45 }
46 
51 {
52  return m_lineEdit;
53 }
54 
60 inline void PathSelection::provideCustomFileMode(QFileDialog::FileMode customFileMode)
61 {
62  m_customMode = customFileMode;
63 }
64 
71 inline void PathSelection::provideCustomFileDialog(QFileDialog *customFileDialog)
72 {
73  m_customDialog = customFileDialog;
74 }
75 } // namespace Widgets
76 
77 #endif // WIDGETS_PATHSELECTION_H
void provideCustomFileMode(QFileDialog::FileMode customFileMode)
Can be used to provide a custom file mode.
Definition: pathselection.h:60
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
void provideCustomFileDialog(QFileDialog *customFileDialog)
Can be used to provide a custom file dialog.
Definition: pathselection.h:71
Provides a set of extended widgets such as ClearLineEdit and ClearComboBox.
Definition: buttonoverlay.h:13
A QLineEdit with a QPushButton next to it which allows to select file/directory via QFileDialog...
Definition: pathselection.h:15
A QLineEdit with an embedded button for clearing its contents.
Definition: clearlineedit.h:14
ClearLineEdit * lineEdit()
Returns the line edit with the selected path.
Definition: pathselection.h:42