Qt Utilities 6.14.3
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Loading...
Searching...
No Matches
QtUtilities::IconButton Class Reference

A simple QAbstractButton implementation displaying a QPixmap. More...

#include <iconbutton.h>

Inheritance diagram for QtUtilities::IconButton:
[legend]
Collaboration diagram for QtUtilities::IconButton:
[legend]

Public Member Functions

 IconButton (QWidget *parent=nullptr)
 Constructs an icon button.
 
 ~IconButton () override
 Destroys the icon button.
 
const QPixmap & pixmap () const
 Returns the pixmap.
 
void setPixmap (const QPixmap &pixmap)
 Sets the pixmap.
 
QSize sizeHint () const override
 

Static Public Member Functions

static IconButtonfromAction (QAction *action, std::uintptr_t id=0)
 Creates an IconButton for the specified action.
 

Static Public Attributes

static constexpr auto defaultPixmapSize = QSize(16, 16)
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
void keyReleaseEvent (QKeyEvent *event) override
 

Properties

QPixmap pixmap
 

Detailed Description

A simple QAbstractButton implementation displaying a QPixmap.

Definition at line 15 of file iconbutton.h.

Constructor & Destructor Documentation

◆ IconButton()

QtUtilities::IconButton::IconButton ( QWidget * parent = nullptr)
explicit

Constructs an icon button.

Definition at line 22 of file iconbutton.cpp.

◆ ~IconButton()

QtUtilities::IconButton::~IconButton ( )
override

Destroys the icon button.

Definition at line 32 of file iconbutton.cpp.

Member Function Documentation

◆ fromAction()

IconButton * QtUtilities::IconButton::fromAction ( QAction * action,
std::uintptr_t id = 0 )
static

Creates an IconButton for the specified action.

Remarks
Calling this function on the same action twice with the same id yields the same instance.

Definition at line 41 of file iconbutton.cpp.

◆ keyPressEvent()

void QtUtilities::IconButton::keyPressEvent ( QKeyEvent * event)
overrideprotected

Definition at line 110 of file iconbutton.cpp.

◆ keyReleaseEvent()

void QtUtilities::IconButton::keyReleaseEvent ( QKeyEvent * event)
overrideprotected

Definition at line 119 of file iconbutton.cpp.

◆ paintEvent()

void QtUtilities::IconButton::paintEvent ( QPaintEvent * event)
overrideprotected

Definition at line 86 of file iconbutton.cpp.

◆ pixmap()

const QPixmap & QtUtilities::IconButton::pixmap ( ) const
inline

Returns the pixmap.

Definition at line 46 of file iconbutton.h.

◆ setPixmap()

void QtUtilities::IconButton::setPixmap ( const QPixmap & pixmap)
inline

Sets the pixmap.

Definition at line 54 of file iconbutton.h.

◆ sizeHint()

QSize QtUtilities::IconButton::sizeHint ( ) const
override

Definition at line 76 of file iconbutton.cpp.

Member Data Documentation

◆ defaultPixmapSize

auto QtUtilities::IconButton::defaultPixmapSize = QSize(16, 16)
staticconstexpr

Definition at line 28 of file iconbutton.h.

Property Documentation

◆ pixmap

QPixmap QtUtilities::IconButton::pixmap
readwrite

Definition at line 17 of file iconbutton.h.


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