Qt 4.8
Public Functions | List of all members
QIconEngine Class Referenceabstract

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

#include <qiconengine.h>

Inheritance diagram for QIconEngine:
QIconEngineV2 QIconLoaderEngine QPixmapIconEngine QSvgIconEngine

Public Functions

virtual QSize actualSize (const QSize &size, QIcon::Mode mode, QIcon::State state)
 Returns the actual size of the icon the engine provides for the requested size, mode and state. More...
 
virtual void addFile (const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state)
 Called by QIcon::addFile(). More...
 
virtual void addPixmap (const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state)
 Called by QIcon::addPixmap(). More...
 
virtual void paint (QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)=0
 Uses the given painter to paint the icon with the required mode and state into the rectangle rect. More...
 
virtual QPixmap pixmap (const QSize &size, QIcon::Mode mode, QIcon::State state)
 Returns the icon as a pixmap with the required size, mode, and state. More...
 
virtual ~QIconEngine ()
 Destroys the icon engine. More...
 

Detailed Description

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

Use QIconEngineV2 instead.

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
QIconEngineV2, QIconEnginePlugin

Definition at line 55 of file qiconengine.h.

Constructors and Destructors

◆ ~QIconEngine()

QIconEngine::~QIconEngine ( )
virtual

Destroys the icon engine.

Definition at line 96 of file qiconengine.cpp.

97 {
98 }

Functions

◆ actualSize()

QSize QIconEngine::actualSize ( const QSize size,
QIcon::Mode  mode,
QIcon::State  state 
)
virtual

Returns the actual size of the icon the engine provides for the requested size, mode and state.

The default implementation returns the given size.

Reimplemented in QIconLoaderEngine, QPixmapIconEngine, and QSvgIconEngine.

Definition at line 87 of file qiconengine.cpp.

Referenced by QIcon::actualSize(), QIconLoaderEngine::actualSize(), and QIcon::paint().

88 {
89  return size;
90 }

◆ addFile()

void QIconEngine::addFile ( const QString fileName,
const QSize size,
QIcon::Mode  mode,
QIcon::State  state 
)
virtual

Called by QIcon::addFile().

Adds a specialized pixmap from the file with the given fileName, size, mode and state. The default pixmap-based engine stores any supplied file names, and it loads the pixmaps on demand instead of using scaled pixmaps if the size of a pixmap matches the size of icon requested. Custom icon engines that implement scalable vector formats are free to ignores any extra files.

Reimplemented in QPixmapIconEngine, and QSvgIconEngine.

Definition at line 136 of file qiconengine.cpp.

Referenced by QIcon::addFile().

137 {
138 }

◆ addPixmap()

void QIconEngine::addPixmap ( const QPixmap pixmap,
QIcon::Mode  mode,
QIcon::State  state 
)
virtual

Called by QIcon::addPixmap().

Adds a specialized pixmap for the given mode and state. The default pixmap-based engine stores any supplied pixmaps, and it uses them instead of scaled pixmaps if the size of a pixmap matches the size of icon requested. Custom icon engines that implement scalable vector formats are free to ignores any extra pixmaps.

Reimplemented in QPixmapIconEngine, and QSvgIconEngine.

Definition at line 123 of file qiconengine.cpp.

Referenced by QIcon::addPixmap().

124 {
125 }

◆ paint()

void QIconEngine::paint ( QPainter painter,
const QRect rect,
QIcon::Mode  mode,
QIcon::State  state 
)
pure virtual

Uses the given painter to paint the icon with the required mode and state into the rectangle rect.

Implemented in QIconLoaderEngine, QPixmapIconEngine, and QSvgIconEngine.

Referenced by QIcon::paint(), and pixmap().

◆ pixmap()

QPixmap QIconEngine::pixmap ( const QSize size,
QIcon::Mode  mode,
QIcon::State  state 
)
virtual

Returns the icon as a pixmap with the required size, mode, and state.

The default implementation creates a new pixmap and calls paint() to fill it.

Reimplemented in QIconLoaderEngine, QPixmapIconEngine, and QSvgIconEngine.

Definition at line 106 of file qiconengine.cpp.

Referenced by QIcon::pixmap().

107 {
108  QPixmap pm(size);
109  {
110  QPainter p(&pm);
111  paint(&p, QRect(QPoint(0,0),size), mode, state);
112  }
113  return pm;
114 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
virtual void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)=0
Uses the given painter to paint the icon with the required mode and state into the rectangle rect...

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