QIconEngine Class

The QIconEngine class provides an abstract base class for QIcon renderers. More...

Header: #include <QIconEngine>
qmake: QT += gui

Public Types

struct AvailableSizesArgument
struct ScaledPixmapArgument
enum IconEngineHook { AvailableSizesHook, IconNameHook, IsNullHook, ScaledPixmapHook }

Detailed Description

An icon engine provides the rendering functions for a QIcon. Each icon has a corresponding icon engine that is responsible for drawing the icon with a requested size, mode and state.

The icon is rendered by the paint() function, and the icon can additionally be obtained as a pixmap with the pixmap() function (the default implementation simply uses paint() to achieve this). The addPixmap() function can be used to add new pixmaps to the icon engine, and is used by QIcon to add specialized custom pixmaps.

The paint(), pixmap(), and addPixmap() functions are all virtual, and can therefore be reimplemented in subclasses of QIconEngine.

See also QIconEnginePlugin.

Member Type Documentation

enum QIconEngine::IconEngineHook

These enum values are used for virtual_hook() to allow additional queries to icon engine without breaking binary compatibility.

ConstantValueDescription
QIconEngine::AvailableSizesHook1Allows to query the sizes of the contained pixmaps for pixmap-based engines. The data argument of the virtual_hook() function is a AvailableSizesArgument pointer that should be filled with icon sizes. Engines that work in terms of a scalable, vectorial format normally return an empty list.
QIconEngine::IconNameHook2Allows to query the name used to create the icon, for example when instantiating an icon using QIcon::fromTheme().
QIconEngine::IsNullHook3Allow to query if this engine represents a null icon. The data argument of the virtual_hook() is a pointer to a bool that can be set to true if the icon is null. This enum value was added in Qt 5.7.
QIconEngine::ScaledPixmapHook4Provides a way to get a pixmap that is scaled according to the given scale (typically equal to the device pixel ratio). The data argument of the virtual_hook() function is a ScaledPixmapArgument pointer that contains both the input and output arguments. This enum value was added in Qt 5.9.

This enum was introduced or modified in Qt 4.5.

See also virtual_hook().