Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  Structure  · 

QIconSet Class Reference


The QIconSet class provides a set of differently styled and sized icons. More...

#include <qiconset.h>

List of all member functions.

Public Members

  • enum Size { Automatic, Small, Large }
  • enum Mode { Normal, Disabled, Active }
  • QIconSet () 
  • QIconSet ( const QPixmap &, Size = Automatic ) 
  • QIconSet ( const QPixmap & smallPix, const QPixmap & largePix ) 
  • QIconSet ( const QIconSet & ) 
  • virtual ~QIconSet () 
  • void reset ( const QPixmap &, Size ) 
  • virtual void setPixmap ( const QPixmap &, Size, Mode = Normal ) 
  • virtual void setPixmap ( const QString &, Size, Mode = Normal ) 
  • QPixmap pixmap ( Size, Mode ) const
  • QPixmap pixmap ( Size s, bool enabled ) const
  • QPixmap pixmap () const
  • bool isGenerated ( Size, Mode ) const
  • bool isNull () const
  • void detach () 
  • QIconSet& operator= ( const QIconSet & ) 

Detailed Description

The QIconSet class provides a set of differently styled and sized icons.

Once a QIconSet is fed some pixmaps, it can generate smaller, larger, active and disabled pixmaps. Such pixmaps are used by QToolButton, QHeader, QPopupMenu, etc. to show an icon representing a piece of functionality.

The simplest usage of QIconSet is to create one from a QPixmap then use it, allowing Qt to work out all the required icon sizes. For example:

  QToolButton *tb = new QToolButton( QIconSet( QPixmap("open.xpm") ), ... );

Using whichever pixmaps you specify as a base, QIconSet provides a set of six icons each with a Size and a Mode:

  • Small Normal - can only be calculated from Large Normal.
  • Small Disabled - calculated from Large Disabled or Small Normal.
  • Small Active - same as Small Normal unless you set it.
  • Large Normal - can only be calculated from Small Normal.
  • Large Disabled - calculated from Small Disabled or Large Normal.
  • Large Active - same as Large Normal unless you set it.

You can set any of the icons using setPixmap() and when you retrieve one using pixmap(Size,Mode), QIconSet will compute it from the closest other icon and cache it for later.

The Disabled appearance is computed using a "shadow" algorithm which produces results very similar to that used in Microsoft Windows 95.

The Active appearance is identical to the Normal appearance unless you use setPixmap() to set it to something special.

When scaling icons, QIconSet uses smooth scaling, which can partially blend the color component of pixmaps. If the results look poor, the best solution is to supply both large and small sizes of pixmap.

QIconSet provides a function, isGenerated(), that indicates whether an icon was set by the application programmer or computed by QIconSet itself.

Making classes that use QIconSet

If you write your own widgets that have an option to set a small pixmap, you should consider instead, or additionally, allowing a QIconSet to be set for that pixmap. The Qt class QToolButton is an example of such a widget.

Provide a method to set a QIconSet, and when you draw the icon, choose whichever icon is appropriate for the current state of your widget. For example:

  void YourWidget::drawIcon( QPainter* p, QPoint pos )
  {
      p->drawPixmap( pos, icons->pixmap(isEnabled(), QIconSet::Small) );
  }

You might also make use of the Active mode, perhaps making your widget Active when the mouse in inside the widget (see QWidget::enterEvent), while the mouse is pressed pending the release that will activate the function, or when it is the currently selected item.

See also QPixmap, QLabel, QToolButton, QPopupMenu, QIconViewItem::setViewMode(), QMainWindow::setUsesBigPixmaps() and GUI Design Handbook: Iconic Label


Member Type Documentation

QIconSet::Mode

This enum type describes the mode for which a pixmap is intended to be provided. The currently defined modes are:

  • Normal - the pixmap to be displayed when the user is not interacting with the icon, but when the functionality represented by the icon is available.
  • Disabled - the pixmap to be displayed when the functionality represented by the icon is not available.
  • Active - the pixmap to be displayed when the functionality represented by the icon is available and the user is interacting with the icon, such as by pointing at it or by invoking it.

QIconSet::Size

This enum type describes the size for which a pixmap is intended to be provided. The currently defined sizes are:

  • Automatic - the size of the pixmap is determined from its pixel size. This is a useful default.
  • Small - the pixmap is the smaller of two.
  • Large - the pixmap is the larger of two

If a Small pixmap is not set by QIconSet::setPixmap(), then the Large pixmap may be automatically scaled to two-thirds of its size to generate the Small pixmap. Conversely, a Small pixmap will be automatically scaled up by 50% to create a Large pixmap if needed.

See also setPixmap(), pixmap(), QIconViewItem::setViewMode() and QMainWindow::setUsesBigPixmaps().


Member Function Documentation

QIconSet::QIconSet ()

Constructs an icon set of null pixmaps. Use setPixmap(), reset(), or operator=() to set some pixmaps.

See also reset().

QIconSet::QIconSet ( const QPixmap & pixmap, Size size = Automatic )

Constructs an icon set for which the Normal pixmap is pixmap, which is assumed to be the given size.

The default for size is Automatic, which means that QIconSet will determine if the pixmap is Small or Large from its pixel size. Pixmaps less than 23 pixels wide are considered to be Small.

See also reset().

QIconSet::QIconSet ( const QPixmap & smallPix, const QPixmap & largePix )

Creates an iconset which uses the pixmap smallPix for for displaying small a small icon, and largePix for displaying a large one.

QIconSet::QIconSet ( const QIconSet & other )

Constructs a copy of other. This is very fast.

QIconSet::~QIconSet () [virtual]

Destructs the icon set and frees any allocated resources.

void QIconSet::detach ()

Detaches this icon set from others with which it may share data.

You will never need to call this function; other QIconSet functions call it as necessary.

bool QIconSet::isGenerated ( Size s, Mode m ) const

Returns TRUE if the variant with size s and mode m was automatically generated, and FALSE if it was not. This mainly useful for development purposes.

bool QIconSet::isNull () const

Returns TRUE if the icon set is empty. Currently, a QIconSet is never empty (although it may contain null pixmaps).

QIconSet & QIconSet::operator= ( const QIconSet & other )

Assigns other to this icon set and returns a reference to this icon set.

This is very fast.

See also detach().

QPixmap QIconSet::pixmap () const

Returns the pixmap originally provided to the constructor or to reset(). This is the Normal pixmap of unspecified Size.

See also reset().

QPixmap QIconSet::pixmap ( Size s, Mode m ) const

Returns a pixmap with size s and mode m, generating one if needed. Generated pixmaps are cached.

QPixmap QIconSet::pixmap ( Size s, bool enabled ) const

Returns a pixmap with size s, and Mode either Normal or Disabled, depending on the value of enabled.

void QIconSet::reset ( const QPixmap & pm, Size s )

Sets this icon set to provide pm for the Normal pixmap, assuming it to be of size s.

This is equivalent to assigning QIconSet(pm,s) to this icon set.

void QIconSet::setPixmap ( const QPixmap & pm, Size size, Mode mode = Normal )

Sets this icon set to provide pm for a size and mode. It may also use pm for deriving some other varieties if those are not set.

The size can be one of Automatic, Large or Small. If Automatic is used, QIconSet will determine if the pixmap is Small or Large from its pixel size. Pixmaps less than 23 pixels wide are considered to be Small.

See also reset().

void QIconSet::setPixmap ( const QString & fileName, Size s, Mode m = Normal )

Sets this icon set to load fileName as a pixmap and provide it for size s and mode m. It may also use the pixmap for deriving some other varieties if those are not set.

The size can be one of Automatic, Large or Small. If Automatic is used, QIconSet will determine if the pixmap is Small or Large from its pixel size. Pixmaps less than 23 pixels wide are considered to be Small.


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2005 Trolltech, all rights reserved.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Labs au hasard

Logo

Le moteur de rendu OpenVG

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 2.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web