KIconUtils Namespace

Provides utility functions for icons. More...

Header: #include <KIconUtils>
CMake: find_package(KF6 REQUIRED COMPONENTS GuiAddons)
target_link_libraries(mytarget PRIVATE KF6::GuiAddons)

Functions

QIcon addOverlay(const QIcon &icon, const QIcon &overlay, Qt::Corner position)
QIcon addOverlays(const QIcon &icon, const QHash<Qt::Corner, QIcon> &overlays)
(since 5.90) QIcon addOverlays(const QIcon &icon, const QStringList &overlays)
(since 5.82) QIcon addOverlays(const QString &iconName, const QStringList &overlays)

Detailed Description

Function Documentation

QIcon KIconUtils::addOverlay(const QIcon &icon, const QIcon &overlay, Qt::Corner position)

Adds the overlay over the icon in the specified position

The overlay icon is scaled down approx. to 1/3 or 1/4 (depending on the icon size) and placed in one of the corners of the base icon.

QIcon KIconUtils::addOverlays(const QIcon &icon, const QHash<Qt::Corner, QIcon> &overlays)

Adds overlays over the icon

The overlays is a QHash of Qt::Corner and QIcon. The Qt::Corner value decides where the overlay icon will be painted, the QIcon value is the overlay icon to be painted.

The overlay icon is scaled down to 1/3 or 1/4 (depending on the icon size) and placed in one of the corners of the base icon.

[since 5.90] QIcon KIconUtils::addOverlays(const QIcon &icon, const QStringList &overlays)

Adds up to four overlays over the icon.

The overlays is a QStringList of icon names (e.g. the emblems that are drawn on icons in Dolphin and KFileWidget, e.g. symlink, un-mounted device ...etc).

Overlays are added in this order:

  • first icon is used to paint an overlay on the bottom-right corner
  • second icon on the bottom-left corner
  • third icon on the top-left corner
  • fourth icon on the top-right corner

Each overlay icon is scaled down to 1/3 or 1/4 (depending on the icon size).

This function was introduced in 5.90.

[since 5.82] QIcon KIconUtils::addOverlays(const QString &iconName, const QStringList &overlays)

Adds up to four overlays on the icon constructed from iconName.

The overlays is a QStringList of icon names (e.g. the emblems that are drawn on icons in Dolphin and KFileWidget, e.g. symlink, un-mounted device ...etc).

Overlays are added in this order:

  • first icon is used to paint an overlay on the bottom-right corner
  • second icon on the bottom-left corner
  • third icon on the top-left corner
  • fourth icon on the top-right corner

Each overlay icon is scaled down to 1/3 or 1/4 (depending on the icon size).

All QIcon objects are constructed using QIcon::fromTheme().

This function was introduced in 5.82.