QIconSet(3qt)
π QIconSet π
ok so bestie, welcome to QIconSet β it's a page from the Qt manual, section 3qt. Sit down, grab a boba, and let's get into it because this one is actually kinda iconic. π
β¨ NAME β¨
QIconSet β a whole vibe of icons with different styles and sizes π¦
β¨ SYNOPSIS β¨
#include <qiconset.h>
πΈ Public Members πΈ
enum Size { Automatic, Small, Large }
enum Mode { Normal, Disabled, Active }
enum State { On, Off }
QIconSet ()
QIconSet ( const QPixmap & pixmap, Size size = Automatic )
QIconSet ( const QPixmap & smallPix, const QPixmap & largePix )
QIconSet ( const QIconSet & other )
virtual ~QIconSet ()
void reset ( const QPixmap & pixmap, Size size )
virtual void setPixmap ( const QPixmap & pixmap, Size size, Mode mode =
Normal, State state = Off )
virtual void setPixmap ( const QString & fileName, Size size, Mode mode
= Normal, State state = Off )
QPixmap pixmap ( Size size, Mode mode, State state = Off ) const
QPixmap pixmap ( Size size, bool enabled, State state = Off ) const
(obsolete)
QPixmap pixmap () const
bool isGenerated ( Size size, Mode mode, State state = Off ) const
void clearGenerated ()
void installIconFactory ( QIconFactory * factory )
bool isNull () const
void detach ()
QIconSet & operator= ( const QIconSet & other )
π Static Public Members π
void setIconSize ( Size which, const QSize & size )
const QSize & iconSize ( Size which )
β¨ DESCRIPTION β¨
ok so the QIconSet class? it's literally a set of icons with different styles and sizes. no cap. π
A QIconSet can generate smaller, larger, active, and disabled pixmaps from the set of icons you give it. Those pixmaps get used by QToolButton, QHeader, QPopupMenu, etc. to show an icon that represents a particular action. it's giving β¨teamworkβ¨
The simplest use of QIconSet is to make one from a QPixmap and then just⦠use it, letting Qt work out all the required icon styles and sizes for you. like, Qt handles it, bestie. for example:
QToolButton *but = 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, Small Disabled, Small Active, Large Normal, Large Disabled, and Large Active. six icons, one glow-up. π
An additional set of six icons can be provided for widgets that have an "On" or "Off" state, like checkable menu items or toggleable toolbuttons. If you provide pixmaps for the "On" state, but not for the "Off" state, the QIconSet will provide the "Off" pixmaps. You may specify icons for both states if you wish. your call, main character. π«Ά
You can set any of the icons using setPixmap().
When you retrieve a pixmap using pixmap(Size, Mode, State), QIconSet will return the icon that has been set or previously generated for that size, mode and state combination. If none is available, QIconSet will ask the icon factory. If the icon factory cannot provide any (that's the default btw), QIconSet generates a pixmap based on the pixmaps it has been given and returns it. so it's never gonna leave you empty-handed fr fr.
The Disabled appearance is computed using an algorithm that produces results very similar to those used in Microsoft Windows 95. (yes, really. vintage π). 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 pixmaps in both large and small sizes. lowkey the move. π¨
You can use the static function setIconSize() to set the preferred size of the generated large/small icons. The default small size is 22 x 22, while the default large size is 32 x 32. These sizes only affect generated icons β important, don't forget it. πΈ
The isGenerated() function returns TRUE if an icon was generated by QIconSet or by a factory; clearGenerated() clears all cached pixmaps. cache cleanse, we love to see it. β¨
π Making Classes that Use QIconSet π
If you write your own widgets that have an option to set a small pixmap, consider allowing a QIconSet to be set for that pixmap. The Qt class QToolButton is an example of such a widget. (iconic behavior, learn from it π«Ά)
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 MyWidget::drawIcon( QPainter* p, QPoint pos )
{
p->drawPixmap( pos, icons->pixmap(
QIconSet::Small,
isEnabled() ? QIconSet::Normal :
QIconSet::Disabled,
isEnabled() ? QIconSet::On :
QIconSet::Off));
}
You might also make use of the Active mode β perhaps making your widget Active when the mouse is over 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. If the widget can be toggled, the "On" mode might be used to draw a different icon. so many options, so much range. π
(there's an image right here in the original page β it got omitted π just imagine a lil icon grid showing off all the modes and sizes, it's very cutesy)
See also QIconFactory, QPixmap, QMainWindow::usesBigPixmaps, GUI Design Handbook: Iconic Label, Graphics Classes, Image Processing Classes, and Implicitly and Explicitly Shared Classes. π
π¦ Member Type Documentation π¦
QIconSet::Mode
This enum type describes the mode for which a pixmap is intended to be used. The currently defined modes are:
QIconSet::Normalβ Display the pixmap when the user is not interacting with the icon, but the functionality represented by the icon is available. (chill mode π)QIconSet::Disabledβ Display the pixmap when the functionality represented by the icon is not available. (sad mode π)QIconSet::Activeβ Display the pixmap when the functionality represented by the icon is available and the user is interacting with the icon, for example, moving the mouse over it or clicking it. (main character mode π)
QIconSet::Size
This enum type describes the size at which a pixmap is intended to be used. The currently defined sizes are:
QIconSet::Automaticβ The size of the pixmap is determined from its pixel size. This is a useful default.QIconSet::Smallβ The pixmap is the smaller of two.QIconSet::Largeβ The pixmap is the larger of two.
If a Small pixmap is not set by QIconSet::setPixmap(), the Large pixmap will be automatically scaled down to the size of a small pixmap to generate the Small pixmap when required. Similarly, a Small pixmap will be automatically scaled up to generate a Large pixmap. The preferred sizes for large/small generated icons can be set using setIconSize(). it justβ¦ handles it. periodt. β¨
See also setIconSize(), iconSize(), setPixmap(), pixmap(), and QMainWindow::usesBigPixmaps.
QIconSet::State
This enum describes the state for which a pixmap is intended to be used. The state can be:
QIconSet::Offβ Display the pixmap when the widget is in an "off" stateQIconSet::Onβ Display the pixmap when the widget is in an "on" state
See also setPixmap() and pixmap().
β¨ MEMBER FUNCTION DOCUMENTATION β¨
QIconSet::QIconSet ()
Constructs a null icon set. empty. blank. a fresh start bestie π«§
See also setPixmap() and 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 of size size.
The default for size is Automatic, which means that QIconSet will determine whether the pixmap is Small or Large from its pixel size. Pixmaps less than the width of a small generated icon are considered to be Small. You can use setIconSize() to set the preferred size of a generated icon. it'll figure it out, it's smart like that π
See also setIconSize() and reset().
QIconSet::QIconSet ( const QPixmap & smallPix, const QPixmap & largePix )
Creates an iconset which uses the pixmap smallPix for displaying a small icon, and the pixmap largePix for displaying a large icon. (yes, the original really does say "for for" β we're keeping it, no edits, no notes π«Ά)
QIconSet::QIconSet ( const QIconSet & other )
Constructs a copy of other. This is very fast. β‘ slay.
QIconSet::~QIconSet () [virtual]
Destroys the icon set and frees any allocated resources. bye bestie, clean exit π
void QIconSet::clearGenerated ()
Clears all cached pixmaps, including those obtained from an eventual QIconFactory. out with the old β¨
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. it's giving "don't worry about it, I got this" π
const QSize & QIconSet::iconSize ( Size which ) [static]
If which is Small, returns the preferred size of a small generated icon; if which is Large, returns the preferred size of a large generated icon.
See also setIconSize().
void QIconSet::installIconFactory ( QIconFactory * factory )
Installs factory as the icon factory for this iconset. The icon factory is used to generates pixmaps not set by the user. (again, "to generates" β original text, untouched, we respect the source π)
If no icon factory is installed, QIconFactory::defaultFactory() is used.
bool QIconSet::isGenerated ( Size size, Mode mode, State state = Off ) const
Returns TRUE if the pixmap with size size, mode mode and state state is generated from other pixmaps; otherwise returns FALSE.
A pixmap obtained from a QIconFactory is considered non-generated. important distinction, iykyk π¦
bool QIconSet::isNull () const
Returns TRUE if the icon set is empty; otherwise returns FALSE.
QIconSet & QIconSet::operator= ( const QIconSet & other )
Assigns other to this icon set and returns a reference to this icon set.
See also detach().
QPixmap QIconSet::pixmap ( Size size, Mode mode, State state = Off ) const
Returns a pixmap with size size, mode mode and state state, generating one if necessary. Generated pixmaps are cached. π§Ί
QPixmap QIconSet::pixmap ( Size size, bool enabled, State state = Off ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code. π¨ like, do not. bestie, I'm begging.
This is the same as pixmap(size, enabled, state).
QPixmap QIconSet::pixmap () const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the pixmap originally provided to the constructor or to reset(). This is the Normal pixmap of unspecified Size. the OG, the original, the blueprint π
See also reset().
void QIconSet::reset ( const QPixmap & pixmap, Size size )
Sets this icon set to use pixmap pixmap for the Normal pixmap, assuming it to be of size size.
This is equivalent to assigning QIconSet(pixmap, size) to this icon set.
This function does nothing if pixmap is a null pixmap. (nothing. zero. nada. π)
void QIconSet::setIconSize ( Size which, const QSize & size ) [static]
Set the preferred size for all small or large icons that are generated after this call. If which is Small, sets the preferred size of small generated icons to size. Similarly, if which is Large, sets the preferred size of large generated icons to size.
Note that cached icons will not be regenerated, so it is recommended that you set the preferred icon sizes before generating any icon sets. Also note that the preferred icon sizes will be ignored for icon sets that have been created using both small and large pixmaps. order matters, bestie. don't fight it. πΈ
See also iconSize().
(part 1 of 2 β there's more coming, don't go anywhere π)
void QIconSet::setPixmap ( const QPixmap & pixmap, Size size, Mode mode = Normal, State state = Off )[virtual] β okay so this is THE one, bestie π it sets this icon set to hand outpixmapfor the combo ofsize,modeandstateyou asked for. And the plot twist? The icon set may also usepixmapto generate other pixmaps, but only if those aren't explicitly set already. So it's like, generous, but not pushy. β¨
The size can be one of Automatic, Large or Small β that's the whole menu, no secret fourth option π. And if you go with Automatic, QIconSet will figure out from the pixmap's pixel size whether it's Small or Large all on its own. Very main character, very self-sufficient.
Here's the tea on the sizing rule π«: pixmaps that are less than the width of a small generated icon get counted as Small. And if you wanna have opinions about how big a generated icon should be, you use setIconSize() to set the preferred size. Slay.
Heads up bestie π this function does nothing if pixmap is a null pixmap. Like, literally nothing. It's giving "I'm not doing that" energy.
See also reset(). π
void QIconSet::setPixmap ( const QString & fileName, Size size, Mode mode = Normal, State state = Off )[virtual] β this is an overloaded member function, provided for convenience π«Ά. It behaves essentially like the above function β same vibe, same energy, just taking afileNameinstead. And the cute part? The pixmap gets loaded fromfileNamewhen it becomes necessary. Lazy loading, but make it iconic π (it doesn't load early, it waits for its moment β¨).
π SEE ALSO π
π COPYRIGHT π
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. π (yes, the whole thing β go read the file, bestie, it's all in there)
π¦ AUTHOR π¦
Generated automatically from the source code. π€ Not a human, not a poet, just a build script doing its thing. No cap.
π BUGS π
Okay so if you find a bug in Qt β and listen, it happens to the best of us π β please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. π«Ά (fr fr, they mean it)
The definitive Qt documentation is provided in HTML format, and it lives at $QTDIR/doc/html. You can read it using Qt Assistant or with a web browser π. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. π (it's giving "we love you but this isn't our canon")
If you find errors in this manual page, please report them to qt-bugs@trolltech.com π§. Please include the name of the manual page (qiconset.3qt) and the Qt version (3.3.8). That's it, that's the whole ask, thank you bestie π
And that's a wrap on QIconSet(3qt)! β¨ This little gem came from Trolltech AS, dated 2 February 2007 β genuinely ancient in internet years but the vibes are timeless, iykyk ππ
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms