Qt Utilities 6.5.1
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
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(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered)
18public:
19 ColorButton(QWidget *parent = nullptr);
20 ~ColorButton() override;
21
22 bool isBackgroundCheckered() const;
23 void setBackgroundCheckered(bool checkered);
24
25 QColor color() const;
26
27public Q_SLOTS:
28 void setColor(const QColor &color);
29
30Q_SIGNALS:
31 void colorChanged(const QColor &color);
32
33protected:
34 void paintEvent(QPaintEvent *event) override;
35 void mousePressEvent(QMouseEvent *event) override;
36 void mouseMoveEvent(QMouseEvent *event) override;
37#ifndef QT_NO_DRAGANDDROP
38 void dragEnterEvent(QDragEnterEvent *event) override;
39 void dragLeaveEvent(QDragLeaveEvent *event) override;
40 void dropEvent(QDropEvent *event) override;
41#endif
42
43private:
44 QScopedPointer<class ColorButtonPrivate> d_ptr;
45 Q_DECLARE_PRIVATE(ColorButton)
46 Q_DISABLE_COPY(ColorButton)
47 Q_PRIVATE_SLOT(d_func(), void slotEditColor())
48};
49} // namespace QtUtilities
50
51#endif // WIDGETS_COLORBUTTON_H
The ColorButton class is used by PaletteEditor.
Definition: colorbutton.h:15
void colorChanged(const QColor &color)
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.