Qt Utilities 6.14.0
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Loading...
Searching...
No Matches
colorbutton.h
Go to the documentation of this file.
1#ifndef WIDGETS_COLORBUTTON_H
2#define WIDGETS_COLORBUTTON_H
3
4#include "../global.h"
5
6#include <QToolButton>
7
8namespace QtUtilities {
9
15class QT_UTILITIES_EXPORT ColorButton : public QToolButton {
16 Q_OBJECT
17 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
18 Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered)
19public:
20 ColorButton(QWidget *parent = nullptr);
21 ~ColorButton() override;
22
23 bool isBackgroundCheckered() const;
24 void setBackgroundCheckered(bool checkered);
25
26 QColor color() const;
27
28public Q_SLOTS:
29 void setColor(const QColor &color);
30
31Q_SIGNALS:
32 void colorChanged(const QColor &color);
33
34protected:
35 void paintEvent(QPaintEvent *event) override;
36 void mousePressEvent(QMouseEvent *event) override;
37 void mouseMoveEvent(QMouseEvent *event) override;
38#ifndef QT_NO_DRAGANDDROP
39 void dragEnterEvent(QDragEnterEvent *event) override;
40 void dragLeaveEvent(QDragLeaveEvent *event) override;
41 void dropEvent(QDropEvent *event) override;
42#endif
43
44private:
45 QScopedPointer<class ColorButtonPrivate> d_ptr;
46 Q_DECLARE_PRIVATE(ColorButton)
47 Q_DISABLE_COPY(ColorButton)
48 Q_PRIVATE_SLOT(d_func(), void slotEditColor())
49};
50} // namespace QtUtilities
51
52#endif // WIDGETS_COLORBUTTON_H
The ColorButton class is used by PaletteEditor.
Definition colorbutton.h:15
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition global.h:14