Qt Utilities 6.14.3
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 event(QEvent *event) override;
28 bool eventFilter(QObject *obj, QEvent *event) override;
29
30private Q_SLOTS:
31 void showFileDialog();
32 void setTexts();
33
34private:
35 ClearLineEdit *m_lineEdit;
36 QPushButton *m_button;
37 QFileDialog *m_customDialog;
38 QFileDialog::FileMode m_customMode;
39 static QCompleter *s_completer;
40};
41
46{
47 return m_lineEdit;
48}
49
54{
55 return m_lineEdit;
56}
57
63inline void PathSelection::provideCustomFileMode(QFileDialog::FileMode customFileMode)
64{
65 m_customMode = customFileMode;
66}
67
74inline void PathSelection::provideCustomFileDialog(QFileDialog *customFileDialog)
75{
76 m_customDialog = customFileDialog;
77}
78} // namespace QtUtilities
79
80#endif // WIDGETS_PATHSELECTION_H
A QLineEdit with an embedded button for clearing its contents.
A QLineEdit with a QPushButton next to it which allows to select file/directory via QFileDialog.
void provideCustomFileMode(QFileDialog::FileMode customFileMode)
Can be used to provide a custom file mode.
void provideCustomFileDialog(QFileDialog *customFileDialog)
Can be used to provide a custom file dialog.
ClearLineEdit * lineEdit()
Returns the line edit with the selected path.
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition global.h:14