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

Composite widget combining a QLabel with a QToolButton. More...

#include <buttonlabel.h>

+ Inheritance diagram for ButtonLabel:
+ Collaboration diagram for ButtonLabel:

Signals

void clicked ()
 Emitted when the tool button is clicked.
 
void activeChanged ()
 Emitted when the active state changes.
 

Public Member Functions

 ButtonLabel (QWidget *parent=nullptr)
 Construct an empty ButtonLabel.
 
 ButtonLabel (const QString &text, QWidget *parent=nullptr)
 Construct with initial label text.
 
QString text () const
 Return the current label text.
 
void setText (const QString &text)
 Set the label text.
 
void setIcon (const QIcon &activeIcon, const QIcon &inactiveIcon=QIcon())
 Set the button icons for active and inactive states.
 
void setButtonAlignment (Qt::Alignment alignment)
 Set the horizontal alignment of the button within the layout.
 
void setActive (bool active)
 Set the active state and update the displayed icon.
 
bool isActive () const
 Return whether the button is in the active state.
 
void setForegroundColor (const QColor &color)
 Set the foreground (text) color.
 
void setBackgroundColor (const QColor &color)
 Set the background color.
 

Detailed Description

Composite widget combining a QLabel with a QToolButton.

ButtonLabel places a text label and a tool button side-by-side. The button can carry separate active and inactive icons and fires a clicked() signal. Colors and alignment are customizable.

Definition at line 18 of file buttonlabel.h.

Constructor & Destructor Documentation

◆ ButtonLabel() [1/2]

ButtonLabel::ButtonLabel ( QWidget *  parent = nullptr)
explicit

Construct an empty ButtonLabel.

Parameters
parentOptional QWidget parent

◆ ButtonLabel() [2/2]

ButtonLabel::ButtonLabel ( const QString &  text,
QWidget *  parent = nullptr 
)
explicit

Construct with initial label text.

Parameters
textInitial label text
parentOptional QWidget parent

Member Function Documentation

◆ isActive()

bool ButtonLabel::isActive ( ) const
inline

Return whether the button is in the active state.

Returns
true if active

Definition at line 70 of file buttonlabel.h.

◆ setActive()

void ButtonLabel::setActive ( bool  active)

Set the active state and update the displayed icon.

Parameters
activetrue to show the active icon

◆ setBackgroundColor()

void ButtonLabel::setBackgroundColor ( const QColor &  color)

Set the background color.

Parameters
colorBackground color

◆ setButtonAlignment()

void ButtonLabel::setButtonAlignment ( Qt::Alignment  alignment)

Set the horizontal alignment of the button within the layout.

Parameters
alignmentQt alignment flags

◆ setForegroundColor()

void ButtonLabel::setForegroundColor ( const QColor &  color)

Set the foreground (text) color.

Parameters
colorForeground color

◆ setIcon()

void ButtonLabel::setIcon ( const QIcon &  activeIcon,
const QIcon &  inactiveIcon = QIcon() 
)

Set the button icons for active and inactive states.

Parameters
activeIconIcon shown when isActive() is true
inactiveIconIcon shown when isActive() is false (optional)

◆ setText()

void ButtonLabel::setText ( const QString &  text)

Set the label text.

Parameters
textNew label text

◆ text()

QString ButtonLabel::text ( ) const
inline

Return the current label text.

Returns
Label text string

Definition at line 39 of file buttonlabel.h.


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