Qt Utilities: widgets/clearspinbox.h Source File

Qt Utilities 6.20.0 Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models

Loading...
Searching...
No Matches
clearspinbox.h
Go to the documentation of this file.
1#ifndef WIDGETS_CLEARSPINBOX_H
2#define WIDGETS_CLEARSPINBOX_H
3
4#include "./buttonoverlay.h"
5
6#include <QLineEdit>
7#include <QSpinBox>
8
9QT_FORWARD_DECLARE_CLASS(QHBoxLayout)
10
11namespace QtUtilities {
12
13class IconButton;
14
15 class QT_UTILITIES_EXPORT ClearSpinBox : public QSpinBox, public ButtonOverlay {
16 Q_OBJECT
17 Q_PROPERTY(bool cleared READ isCleared)
18 Q_PROPERTY(bool minimumHidden READ minimumHidden WRITE setMinimumHidden)
19 Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
20
21public:
22 explicit ClearSpinBox(QWidget *parent = nullptr);
23 ~ClearSpinBox() override;
24 bool minimumHidden() const;
25 void setMinimumHidden(bool value);
26 QString placeholderText() const;
27 void setPlaceholderText(const QString &placeholderText);
28 bool isCleared() const override;
29
30protected:
31 int valueFromText(const QString &text) const override;
32 QString textFromValue(int val) const override;
33
34private Q_SLOTS:
35 void handleValueChanged(int value);
36 void handleClearButtonClicked() override;
37 void handleCustomLayoutCreated() override;
38
39private:
40 bool m_minimumHidden;
41};
42
46inline bool ClearSpinBox::minimumHidden() const
47{
48 return m_minimumHidden;
49}
50
54 inline void ClearSpinBox::setMinimumHidden(bool value)
55{
56 m_minimumHidden = value;
57}
58
63 inline QString ClearSpinBox::placeholderText() const
64{
65 return lineEdit()->placeholderText();
66}
67
72 inline void ClearSpinBox::setPlaceholderText(const QString &placeholderText)
73{
74 lineEdit()->setPlaceholderText(placeholderText);
75}
76} // namespace QtUtilities
77
78#endif // WIDGETS_CLEARSPINBOX_H
buttonoverlay.h
QtUtilities::ButtonOverlay::ButtonOverlay
ButtonOverlay(QWidget *widget)
Constructs a button overlay for the specified widget.
Definition buttonoverlay.cpp:49
QtUtilities::ClearSpinBox::cleared
bool cleared
Definition clearspinbox.h:17
QtUtilities::ClearSpinBox::isCleared
bool isCleared() const override
Returns whether the related widget is cleared.
Definition clearspinbox.cpp:57
QtUtilities::ClearSpinBox::minimumHidden
bool minimumHidden
Definition clearspinbox.h:18
QtUtilities::ClearSpinBox::setMinimumHidden
void setMinimumHidden(bool value)
Sets whether the minimum value should be hidden.
Definition clearspinbox.h:54
QtUtilities::ClearSpinBox::textFromValue
QString textFromValue(int val) const override
Definition clearspinbox.cpp:71
QtUtilities::ClearSpinBox::placeholderText
QString placeholderText
Definition clearspinbox.h:19
QtUtilities::ClearSpinBox::setPlaceholderText
void setPlaceholderText(const QString &placeholderText)
Sets the placeholder text.
Definition clearspinbox.h:72
QtUtilities::ClearSpinBox::ClearSpinBox
ClearSpinBox(QWidget *parent=nullptr)
Constructs a clear spin box.
Definition clearspinbox.cpp:19
QtUtilities::ClearSpinBox::valueFromText
int valueFromText(const QString &text) const override
Definition clearspinbox.cpp:62
QtUtilities::IconButton
A simple QAbstractButton implementation displaying a QPixmap.
Definition iconbutton.h:15
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
text
#define text
Definition xmlparsermacros.h:18