A small, clickable widget that displays a solid color preview.
More...
#include <clickable_color_preview.h>
|
| void | SetColor (const QColor &color) |
| | Sets the background color to be displayed by the preview widget. Updates the widget's palette and triggers a repaint. If the color is invalid, a transparent background is set.
|
| |
|
| void | clicked () |
| | Emitted when the widget is clicked with the left mouse button.
|
| |
|
| void | mousePressEvent (QMouseEvent *event) override |
| | Overridden mouse press event handler. Emits the clicked() signal if the left mouse button is pressed.
|
| |
| void | paintEvent (QPaintEvent *event) override |
| | Overridden paint event handler. Draws the widget's appearance. Fills the background with the color set in the palette (via SetColor) and draws a thin border around the widget.
|
| |
A small, clickable widget that displays a solid color preview.
This widget is typically used in settings panels to show a color and allow the user to click it, usually to open a color picker dialog. It displays the color set by SetColor() as its background and draws a thin border around itself. It emits a clicked() signal when pressed with the left mouse button.
◆ ClickableColorPreview()
| ClickableColorPreview::ClickableColorPreview |
( |
QWidget * | parent = nullptr | ) |
|
|
explicit |
Constructs a ClickableColorPreview widget. Sets a fixed size, enables the pointing hand cursor, and configures background drawing.
- Parameters
-
| parent | Optional parent widget. |
◆ clicked
| void ClickableColorPreview::clicked |
( |
| ) |
|
|
signal |
Emitted when the widget is clicked with the left mouse button.
◆ mousePressEvent()
| void ClickableColorPreview::mousePressEvent |
( |
QMouseEvent * | event | ) |
|
|
overrideprotected |
Overridden mouse press event handler. Emits the clicked() signal if the left mouse button is pressed.
- Parameters
-
◆ paintEvent()
| void ClickableColorPreview::paintEvent |
( |
QPaintEvent * | event | ) |
|
|
overrideprotected |
Overridden paint event handler. Draws the widget's appearance. Fills the background with the color set in the palette (via SetColor) and draws a thin border around the widget.
- Parameters
-
◆ SetColor
| void ClickableColorPreview::SetColor |
( |
const QColor & | color | ) |
|
|
slot |
Sets the background color to be displayed by the preview widget. Updates the widget's palette and triggers a repaint. If the color is invalid, a transparent background is set.
- Parameters
-
| color | The QColor to display. |
The documentation for this class was generated from the following files: