KIconThemes 5.109.0
Properties | Signals | Public Member Functions | List of all members
KIconButton

A pushbutton for choosing an icon. More...

#include <KIconButton>

Properties

QString icon
 
int iconSize
 
bool strictIconSize
 

Signals

void iconChanged (const QString &icon)
 Emitted when the icon has changed.
 

Public Member Functions

 KIconButton (KIconLoader *loader, QWidget *parent)
 Constructs a KIconButton using a specific icon loader.
 
 KIconButton (QWidget *parent=nullptr)
 Constructs a KIconButton using the global icon loader.
 
 ~KIconButton () override
 Destructs the button.
 
int buttonIconSize () const
 Returns the button's icon size.
 
const QString & icon () const
 Returns the name of the selected icon.
 
int iconSize () const
 Returns the icon size set via setIconSize() or 0, if the default icon size will be used.
 
void resetIcon ()
 Resets the icon (reverts to an empty button).
 
void setButtonIconSize (int size)
 Sets the size of the icon to be shown on the button.
 
void setIcon (const QIcon &icon)
 
void setIcon (const QString &icon)
 Sets the button's initial icon.
 
void setIconSize (int size)
 Sets the size of the icon to be shown / selected.
 
void setIconType (KIconLoader::Group group, KIconLoader::Context context, bool user=false)
 Sets the icon group and context.
 
void setStrictIconSize (bool b)
 Sets a strict icon size policy for allowed icons.
 
bool strictIconSize () const
 Returns true if a strict icon size policy is set.
 

Detailed Description

A pushbutton for choosing an icon.

Pressing on the button will open a KIconDialog for the user to select an icon. The current icon will be displayed on the button.

See also
KIconDialog

A push button that allows selection of an icon.

Constructor & Destructor Documentation

◆ KIconButton() [1/2]

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

Constructs a KIconButton using the global icon loader.

Parameters
parentThe parent widget.

◆ KIconButton() [2/2]

KIconButton::KIconButton ( KIconLoader loader,
QWidget *  parent 
)

Constructs a KIconButton using a specific icon loader.

Deprecated:
since 5.104, use KIconButton(QWidget *).
Parameters
loaderThe icon loader to use.
parentThe parent widget.

◆ ~KIconButton()

KIconButton::~KIconButton ( )
override

Destructs the button.

Member Function Documentation

◆ buttonIconSize()

int KIconButton::buttonIconSize ( ) const

Returns the button's icon size.

Since
4.1

◆ icon()

const QString & KIconButton::icon ( ) const

Returns the name of the selected icon.

◆ iconChanged

void KIconButton::iconChanged ( const QString &  icon)
signal

Emitted when the icon has changed.

◆ iconSize()

int KIconButton::iconSize ( ) const

Returns the icon size set via setIconSize() or 0, if the default icon size will be used.

◆ resetIcon()

void KIconButton::resetIcon ( )

Resets the icon (reverts to an empty button).

◆ setButtonIconSize()

void KIconButton::setButtonIconSize ( int  size)

Sets the size of the icon to be shown on the button.

See also
KIconLoader::StdSizes
buttonIconSize
Since
4.1

◆ setIcon()

void KIconButton::setIcon ( const QString &  icon)

Sets the button's initial icon.

◆ setIconSize()

void KIconButton::setIconSize ( int  size)

Sets the size of the icon to be shown / selected.

See also
KIconLoader::StdSizes
iconSize

◆ setIconType()

void KIconButton::setIconType ( KIconLoader::Group  group,
KIconLoader::Context  context,
bool  user = false 
)

Sets the icon group and context.

Use KIconLoader::NoGroup if you want to allow icons for any group in the given context.

◆ setStrictIconSize()

void KIconButton::setStrictIconSize ( bool  b)

Sets a strict icon size policy for allowed icons.

When true, only icons of the specified group's size in setIconType() are allowed, and only icons of that size will be shown in the icon dialog.

◆ strictIconSize()

bool KIconButton::strictIconSize ( ) const

Returns true if a strict icon size policy is set.