Qt Utilities 6.12.0
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Loading...
Searching...
No Matches
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
8QT_FORWARD_DECLARE_CLASS(QPushButton)
9QT_FORWARD_DECLARE_CLASS(QCompleter)
10
11namespace QtUtilities {
12
13class ClearLineEdit;
14
15class QT_UTILITIES_EXPORT PathSelection : public QWidget {
16 Q_OBJECT
17
18public:
19 explicit PathSelection(QWidget *parent = nullptr);
20
21 ClearLineEdit *lineEdit();
22 const ClearLineEdit *lineEdit() const;
23 void provideCustomFileMode(QFileDialog::FileMode customFileMode);
24 void provideCustomFileDialog(QFileDialog *customFileDialog);
25
26protected:
27 bool eventFilter(QObject *obj, QEvent *event) override;
28
29private Q_SLOTS:
30 void showFileDialog();
31
32private:
33 ClearLineEdit *m_lineEdit;
34 QPushButton *m_button;
35 QFileDialog *m_customDialog;
36 QFileDialog::FileMode m_customMode;
37 static QCompleter *s_completer;
38};
39
44{
45 return m_lineEdit;
46}
47
52{
53 return m_lineEdit;
54}
55
61inline void PathSelection::provideCustomFileMode(QFileDialog::FileMode customFileMode)
62{
63 m_customMode = customFileMode;
64}
65
72inline void PathSelection::provideCustomFileDialog(QFileDialog *customFileDialog)
73{
74 m_customDialog = customFileDialog;
75}
76} // namespace QtUtilities
77
78#endif // WIDGETS_PATHSELECTION_H
A QLineEdit with an embedded button for clearing its contents.
Definition: clearlineedit.h:14
A QLineEdit with a QPushButton next to it which allows to select file/directory via QFileDialog.
Definition: pathselection.h:15
void provideCustomFileMode(QFileDialog::FileMode customFileMode)
Can be used to provide a custom file mode.
Definition: pathselection.h:61
void provideCustomFileDialog(QFileDialog *customFileDialog)
Can be used to provide a custom file dialog.
Definition: pathselection.h:72
ClearLineEdit * lineEdit()
Returns the line edit with the selected path.
Definition: pathselection.h:43
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.