KanoopGuiQt 1.3.0
Qt GUI utility library
Loading...
Searching...
No Matches
Label Class Reference

QLabel subclass with font size and color Q_PROPERTYs. More...

#include <label.h>

+ Inheritance diagram for Label:
+ Collaboration diagram for Label:

Public Slots

void setForegroundColor (const QColor &color)
 Set the foreground (text) color and repaint.
 
void setBackgroundColor (const QColor &color)
 Set the background color and repaint.
 

Public Member Functions

 Label (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
 Construct with optional parent and window flags.
 
 Label (const QString &text, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
 Construct with initial text, optional parent and window flags.
 
void setFontPointSize (int size)
 Set the font size in points.
 
void setFontPixelSize (int size)
 Set the font size in pixels.
 
QColor foregroundColor () const
 Return the current foreground color.
 
QColor backgroundColor () const
 Return the current background color.
 
void setDefaultForegroundColor ()
 Reset the foreground color to the palette default.
 
void setDefaultBackgroundColor ()
 Reset the background color to the palette default.
 

Protected Member Functions

virtual void applyStylesheet ()
 Rebuild and apply the stylesheet from current color properties.
 

Properties

QColor foregroundColor
 Foreground (text) color of the label.
 
QColor backgroundColor
 Background color of the label.
 

Detailed Description

QLabel subclass with font size and color Q_PROPERTYs.

Label exposes foregroundColor and backgroundColor as Qt properties, allowing them to be set from Qt Designer or stylesheets. It also provides setFontPointSize() and setFontPixelSize() for quick font-size changes without manual QFont manipulation.

Definition at line 15 of file label.h.

Constructor & Destructor Documentation

◆ Label() [1/2]

Label::Label ( QWidget *  parent = nullptr,
Qt::WindowFlags  f = Qt::WindowFlags() 
)
explicit

Construct with optional parent and window flags.

Parameters
parentOptional QWidget parent
fOptional window flags

◆ Label() [2/2]

Label::Label ( const QString &  text,
QWidget *  parent = nullptr,
Qt::WindowFlags  f = Qt::WindowFlags() 
)
explicit

Construct with initial text, optional parent and window flags.

Parameters
textInitial label text
parentOptional QWidget parent
fOptional window flags

Member Function Documentation

◆ backgroundColor()

QColor Label::backgroundColor ( ) const
inline

Return the current background color.

Returns
Background color

Definition at line 61 of file label.h.

◆ foregroundColor()

QColor Label::foregroundColor ( ) const
inline

Return the current foreground color.

Returns
Foreground (text) color

Definition at line 55 of file label.h.

◆ setBackgroundColor

void Label::setBackgroundColor ( const QColor &  color)
slot

Set the background color and repaint.

Parameters
colorNew background color

◆ setFontPixelSize()

void Label::setFontPixelSize ( int  size)

Set the font size in pixels.

Parameters
sizePixel size

◆ setFontPointSize()

void Label::setFontPointSize ( int  size)

Set the font size in points.

Parameters
sizePoint size

◆ setForegroundColor

void Label::setForegroundColor ( const QColor &  color)
slot

Set the foreground (text) color and repaint.

Parameters
colorNew foreground color

Property Documentation

◆ backgroundColor

QColor Label::backgroundColor
readwrite

Background color of the label.

Definition at line 22 of file label.h.

◆ foregroundColor

QColor Label::foregroundColor
readwrite

Foreground (text) color of the label.

Definition at line 20 of file label.h.


The documentation for this class was generated from the following file: