Qt Utilities: widgets/pathselection.h Source File

Qt Utilities 6.21.2 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
15 class 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
45 inline ClearLineEdit *PathSelection::lineEdit()
46{
47 return m_lineEdit;
48}
49
53 inline const ClearLineEdit *PathSelection::lineEdit() const
54{
55 return m_lineEdit;
56}
57
63 inline void PathSelection::provideCustomFileMode(QFileDialog::FileMode customFileMode)
64{
65 m_customMode = customFileMode;
66}
67
74 inline void PathSelection::provideCustomFileDialog(QFileDialog *customFileDialog)
75{
76 m_customDialog = customFileDialog;
77}
78} // namespace QtUtilities
79
80#endif // WIDGETS_PATHSELECTION_H
QtUtilities::ClearLineEdit
A QLineEdit with an embedded button for clearing its contents.
Definition clearlineedit.h:14
QtUtilities::PathSelection::provideCustomFileMode
void provideCustomFileMode(QFileDialog::FileMode customFileMode)
Can be used to provide a custom file mode.
Definition pathselection.h:63
QtUtilities::PathSelection::provideCustomFileDialog
void provideCustomFileDialog(QFileDialog *customFileDialog)
Can be used to provide a custom file dialog.
Definition pathselection.h:74
QtUtilities::PathSelection::lineEdit
ClearLineEdit * lineEdit()
Returns the line edit with the selected path.
Definition pathselection.h:45
QtUtilities::PathSelection::PathSelection
PathSelection(QWidget *parent=nullptr)
Constructs a path selection widget.
Definition pathselection.cpp:37
QtUtilities::PathSelection::event
bool event(QEvent *event) override
Definition pathselection.cpp:68
QtUtilities::PathSelection::eventFilter
bool eventFilter(QObject *obj, QEvent *event) override
Definition pathselection.cpp:79
global.h
QT_UTILITIES_EXPORT
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition global.h:14
QtUtilities
!
Definition trylocker.h:8