Qt Utilities  5.6.0
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
buttonoverlay.h
Go to the documentation of this file.
1 #ifndef WIDGETS_BUTTONOVERLAY_H
2 #define WIDGETS_BUTTONOVERLAY_H
3 
4 #include "../global.h"
5 
6 #include <QtGlobal>
7 
8 QT_FORWARD_DECLARE_CLASS(QWidget)
9 QT_FORWARD_DECLARE_CLASS(QHBoxLayout)
10 QT_FORWARD_DECLARE_CLASS(QString)
11 QT_FORWARD_DECLARE_CLASS(QPixmap)
12 
13 namespace Widgets {
14 
15 class IconButton;
16 
18 {
19 public:
20  explicit ButtonOverlay(QWidget *widget);
21  virtual ~ButtonOverlay();
22 
23  QHBoxLayout *buttonLayout();
24  bool isClearButtonEnabled() const;
25  void setClearButtonEnabled(bool enabled);
26  bool isInfoButtonEnabled() const;
27  void enableInfoButton(const QPixmap &pixmap, const QString &infoText);
28  void disableInfoButton();
29  void addCustomButton(QWidget *button);
30  void insertCustomButton(int index, QWidget *button);
31  void removeCustomButton(QWidget *button);
32  virtual bool isCleared() const;
33 
34 protected:
35  void updateClearButtonVisibility(bool visible);
36  virtual void handleClearButtonClicked();
37 
38 private:
39  void showInfo();
40 
41  QWidget *m_widget;
42  QWidget *m_buttonWidget;
43  QHBoxLayout *m_buttonLayout;
44  IconButton *m_clearButton;
45  IconButton *m_infoButton;
46 };
47 
51 inline QHBoxLayout *ButtonOverlay::buttonLayout()
52 {
53  return m_buttonLayout;
54 }
55 
59 inline bool ButtonOverlay::isClearButtonEnabled() const
60 {
61  return m_clearButton != nullptr;
62 }
63 
67 inline bool ButtonOverlay::isInfoButtonEnabled() const
68 {
69  return m_infoButton != nullptr;
70 }
71 
72 }
73 
74 #endif // WIDGETS_BUTTONOVERLAY_H
A simple QAbstractButton implementation displaying a QPixmap.
Definition: iconbutton.h:11
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
The ButtonOverlay class is used to display buttons on top of other widgets.
Definition: buttonoverlay.h:17
Provides a set of extended widgets such as ClearLineEdit and ClearComboBox.
Definition: buttonoverlay.h:13