Web Analytics Made Easy - Statcounter
Skip to content

Class SBGUIPushButtonHover#

ClassList > SBGUIPushButtonHover

The SBGUIPushButtonHover class extends QPushButton to create a transparent (without background) button with an icon that changes on hover.More...

  • #include <SBGUIPushButtonHover.hpp>

Inherits the following classes: QPushButton, QPushButton

Public Types#

Type Name
enum IconType
Available icon types.

Public Functions#

Type Name
SBGUIPushButtonHover (QWidget * parent=nullptr)
Constructs a SBGUIPushButtonHover with an optional parent widget.
SBGUIPushButtonHover (const QString & text, QWidget * parent=nullptr)
Constructs a SBGUIPushButtonHover with a given text label and optional parent widget.
IconType getIconType () const
Returns the icon type.
void setIconType (IconType iconType)
Sets the icon type. This will also set the icons to the standard ones for the non Custom and non Undefined icon types.
void setIcons (const QString & iconPath, const QString & hoverIconPath)
Sets two icons: non-hover and on-hover icons. The icon type is set to Custom.
void setIcons (const QIcon & icon, const QIcon & hoverIcon)
Sets two icons: non-hover and on-hover icons. The icon type is set to Custom.
~SBGUIPushButtonHover ()
Destroys the SBGUIPushButtonHover and releases any custom icons.

Protected Functions#

Type Name
void enterEvent (QEnterEvent * event) override
Handles enter events.
void leaveEvent (QEvent * event) override
Handles leave events.

Detailed Description#

Short name: SBPushButtonHover

Public Types Documentation#

enum IconType#

Available icon types.

enum SBGUIPushButtonHover::IconType {
    Undefined,
    Add,
    Edit,
    Remove,
    Delete,
    Clear,
    Reset,
    Copy,
    Custom
};


Public Functions Documentation#

function SBGUIPushButtonHover [1/2]#

Constructs a SBGUIPushButtonHover with an optional parent widget.

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

This overload forwards to the constructor taking a text string with an empty string.

Parameters:

  • parent Parent widget (optional). If nullptr, the button has no parent.

function SBGUIPushButtonHover [2/2]#

Constructs a SBGUIPushButtonHover with a given text label and optional parent widget.

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

Parameters:

  • text The text label for the button.
  • parent The parent widget (optional). If nullptr, the button has no parent.

function getIconType#

Returns the icon type.

IconType SBGUIPushButtonHover::getIconType () const

Returns the current icon type of the button.

Returns:

The icon type.


function setIconType#

Sets the icon type. This will also set the icons to the standard ones for the non Custom and non Undefined icon types.

void SBGUIPushButtonHover::setIconType (
    IconType iconType
) 

Sets the button's icon type, loading standard icons for the specified type.

Parameters:

  • iconType The icon type to set.

function setIcons [1/2]#

Sets two icons: non-hover and on-hover icons. The icon type is set to Custom.

void SBGUIPushButtonHover::setIcons (
    const QString & iconPath,
    const QString & hoverIconPath
) 

Sets custom icons for the button using file paths for the normal and hover states.

Parameters:

  • iconPath File path to the normal state icon.
  • hoverIconPath File path to the hover state icon.

function setIcons [2/2]#

Sets two icons: non-hover and on-hover icons. The icon type is set to Custom.

void SBGUIPushButtonHover::setIcons (
    const QIcon & icon,
    const QIcon & hoverIcon
) 

Sets custom icons for the button using QIcon objects for the normal and hover states.

Parameters:

  • icon The QIcon for the normal state.
  • hoverIcon The QIcon for the hover state.

function ~SBGUIPushButtonHover#

Destroys the SBGUIPushButtonHover and releases any custom icons.

SBGUIPushButtonHover::~SBGUIPushButtonHover () 


Protected Functions Documentation#

function enterEvent#

Handles enter events.

void SBGUIPushButtonHover::enterEvent (
    QEnterEvent * event
) override

Handles the mouse enter event, updating the button icon to the hover version if applicable.

Parameters:

  • event The enter event.

function leaveEvent#

Handles leave events.

void SBGUIPushButtonHover::leaveEvent (
    QEvent * event
) override

Handles the mouse leave event, restoring the button icon to the normal version if applicable.

Parameters:

  • event The leave event.