A custom QLabel that displays text alongside a colored circle with a glow effect.
More...
#include <user_info_label.h>
|
| QSize | minimumSizeHint () const override |
| | Returns the minimum recommended size for the label. Similar to sizeHint, but based on the minimum text size.
|
| |
| void | SetShapeColor (const QColor &color) |
| | Sets the color of the circle and its glow. Triggers a repaint of the label.
|
| |
| QSize | sizeHint () const override |
| | Returns the recommended size for the label. Calculates the size based on the text size plus the space required for the colored circle, its glow, and padding.
|
| |
| | UserInfoLabel (QWidget *parent=nullptr) |
| | Constructs a UserInfoLabel. Initializes default parameters for the circle and glow effect (diameter, pen width, glow layers, spread) and calculates the total space required for the shape.
|
| |
|
| void | paintEvent (QPaintEvent *event) override |
| | Overridden paint event handler. Draws the custom label appearance. Renders the background, the colored circle with its multi-layered glow effect, and finally the label text positioned to the right of the shape.
|
| |
|
| int | circle_diameter_ |
| | Diameter of the main colored circle indicator.
|
| |
| int | glow_layers_ |
| | Number of layers used to render the glow effect.
|
| |
| qreal | glow_spread_ |
| | How much each glow layer expands outwards relatively to the previous one.
|
| |
| qreal | pen_width_ |
| | The thickness of the pen used to draw the main circle.
|
| |
| QColor | shape_color_ |
| | The base color used for the circle and its glow.
|
| |
| int | shape_padding_ |
| | Horizontal padding between the right edge of the glow and the start of the text.
|
| |
| int | total_shape_size_ |
| | Pre-calculated total width required for the circle and its maximum glow extent.
|
| |
A custom QLabel that displays text alongside a colored circle with a glow effect.
This label is designed to show user information (like a username) preceded by a visual indicator (a colored circle). The circle's color can be set using SetShapeColor, and it features a multi-layered glow effect rendered in the paintEvent. The size hint is adjusted to accommodate the circle and its glow.
◆ UserInfoLabel()
| UserInfoLabel::UserInfoLabel |
( |
QWidget * | parent = nullptr | ) |
|
|
explicit |
Constructs a UserInfoLabel. Initializes default parameters for the circle and glow effect (diameter, pen width, glow layers, spread) and calculates the total space required for the shape.
- Parameters
-
| parent | Optional parent widget. |
◆ minimumSizeHint()
| QSize UserInfoLabel::minimumSizeHint |
( |
| ) |
const |
|
override |
Returns the minimum recommended size for the label. Similar to sizeHint, but based on the minimum text size.
- Returns
- The calculated minimum QSize hint.
◆ paintEvent()
| void UserInfoLabel::paintEvent |
( |
QPaintEvent * | event | ) |
|
|
overrideprotected |
Overridden paint event handler. Draws the custom label appearance. Renders the background, the colored circle with its multi-layered glow effect, and finally the label text positioned to the right of the shape.
- Parameters
-
◆ SetShapeColor()
| void UserInfoLabel::SetShapeColor |
( |
const QColor & | color | ) |
|
Sets the color of the circle and its glow. Triggers a repaint of the label.
- Parameters
-
| color | The desired QColor for the shape. |
◆ sizeHint()
| QSize UserInfoLabel::sizeHint |
( |
| ) |
const |
|
override |
Returns the recommended size for the label. Calculates the size based on the text size plus the space required for the colored circle, its glow, and padding.
- Returns
- The calculated QSize hint.
◆ circle_diameter_
| int UserInfoLabel::circle_diameter_ |
|
private |
Diameter of the main colored circle indicator.
◆ glow_layers_
| int UserInfoLabel::glow_layers_ |
|
private |
Number of layers used to render the glow effect.
◆ glow_spread_
| qreal UserInfoLabel::glow_spread_ |
|
private |
How much each glow layer expands outwards relatively to the previous one.
◆ pen_width_
| qreal UserInfoLabel::pen_width_ |
|
private |
The thickness of the pen used to draw the main circle.
◆ shape_color_
| QColor UserInfoLabel::shape_color_ |
|
private |
The base color used for the circle and its glow.
◆ shape_padding_
| int UserInfoLabel::shape_padding_ |
|
private |
Horizontal padding between the right edge of the glow and the start of the text.
◆ total_shape_size_
| int UserInfoLabel::total_shape_size_ |
|
private |
Pre-calculated total width required for the circle and its maximum glow extent.
The documentation for this class was generated from the following files: