Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QIcon Class Reference

List of all members.


Detailed Description

The QIcon class provides scalable icons in different modes and states.

A QIcon can generate smaller, larger, active, and disabled pixmaps from the set of pixmaps it is given. Such pixmaps are used by Qt widgets to show an icon representing a particular action.

The simplest use of QIcon is to create one from a QPixmap file or resource, and then use it, allowing Qt to work out all the required icon styles and sizes. For example:

    QToolButton *button = new QToolButton;
    button->setIcon(QIcon("open.xpm"));

Use the QImageReader::supportedImageFormats() and QImageWriter::supportedImageFormats() functions to retrieve a complete list of the supported file formats.

When you retrieve a pixmap using pixmap(QSize, Mode, State), and no pixmap for this given size, mode and state has been added with addFile() or addPixmap(), then QIcon will generate one on the fly. This pixmap generation happens in a QIconEngine. The default engine scales pixmaps down if required, but never up, and it uses the current style to calculate a disabled appearance. By using custom icon engines, you can customize every aspect of generated icons. With QIconEnginePlugin it is possible to register different icon engines for different file suffixes, so you could provide a SVG icon engine or any other scalable format.

Definition at line 38 of file qicon.h.


Public Types

enum  Mode { Normal, Disabled, Active, Selected }
enum  State { On, Off }

Public Member Functions

QSize actualSize (const QSize &size, Mode mode=Normal, State state=Off) const
void addFile (const QString &fileName, const QSize &size=QSize(), Mode mode=Normal, State state=Off)
void addPixmap (const QPixmap &pixmap, Mode mode=Normal, State state=Off)
bool isDetached () const
bool isNull () const
 operator QVariant () const
QIconoperator= (const QIcon &other)
void paint (QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const
void paint (QPainter *painter, const QRect &rect, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const
QPixmap pixmap (int extent, Mode mode=Normal, State state=Off) const
QPixmap pixmap (int w, int h, Mode mode=Normal, State state=Off) const
QPixmap pixmap (const QSize &size, Mode mode=Normal, State state=Off) const
 QIcon (QIconEngine *engine)
 QIcon (const QString &fileName)
 QIcon (const QIcon &other)
 QIcon (const QPixmap &pixmap)
int serialNumber () const
 ~QIcon ()

Private Attributes

QIconPrivate * d

Friends

Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, const QIcon &)

Related Functions

(Note that these are not member functions.)

QDataStreamoperator>> (QDataStream &stream, QIcon &icon)

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

Generated by  Doxygen 1.6.0   Back to index