Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
The QIcon class provides scalable icons in different modes and states. More...
#include <qicon.h>
Public Member Functions | |
QIcon () noexcept | |
Constructs a null icon. | |
QIcon (const QPixmap &pixmap) | |
Constructs an icon from a pixmap. | |
QIcon (const QIcon &other) | |
Constructs a copy of other. | |
QIcon (QIcon &&other) noexcept | |
Move-constructs a QIcon instance, making it point to the same object that other was pointing to. | |
QIcon (const QString &fileName) | |
Constructs an icon from the file with the given fileName. | |
QIcon (QIconEngine *engine) | |
Creates an icon with a specific icon engine. | |
~QIcon () | |
Destroys the icon. | |
QIcon & | operator= (const QIcon &other) |
Assigns the other icon to this icon and returns a reference to this icon. | |
void | swap (QIcon &other) noexcept |
bool | operator== (const QIcon &) const =delete |
bool | operator!= (const QIcon &) const =delete |
operator QVariant () const | |
Returns the icon as a QVariant. | |
QPixmap | pixmap (const QSize &size, Mode mode=Normal, State state=Off) const |
Returns a pixmap with the requested size, mode, and state, generating one if necessary. | |
QPixmap | pixmap (int w, int h, Mode mode=Normal, State state=Off) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a pixmap of size QSize(w, h). | |
QPixmap | pixmap (int extent, Mode mode=Normal, State state=Off) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a pixmap of size QSize(extent, extent). | |
QPixmap | pixmap (const QSize &size, qreal devicePixelRatio, Mode mode=Normal, State state=Off) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QSize | actualSize (const QSize &size, Mode mode=Normal, State state=Off) const |
Returns the actual size of the icon for the requested size, mode, and state. | |
QString | name () const |
void | paint (QPainter *painter, const QRect &rect, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const |
Uses the painter to paint the icon with specified alignment, required mode, and state into the rectangle rect. | |
void | paint (QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Paints the icon into the rectangle QRect(x, y, w, h). | |
bool | isNull () const |
Returns true if the icon is empty; otherwise returns false . | |
bool | isDetached () const |
void | detach () |
qint64 | cacheKey () const |
Returns a number that identifies the contents of this QIcon object. | |
void | addPixmap (const QPixmap &pixmap, Mode mode=Normal, State state=Off) |
Adds pixmap to the icon, as a specialization for mode and state. | |
void | addFile (const QString &fileName, const QSize &size=QSize(), Mode mode=Normal, State state=Off) |
Adds an image from the file with the given fileName to the icon, as a specialization for size, mode and state. | |
QList< QSize > | availableSizes (Mode mode=Normal, State state=Off) const |
void | setIsMask (bool isMask) |
bool | isMask () const |
DataPtr & | data_ptr () |
Static Public Member Functions | |
static QIcon | fromTheme (const QString &name) |
static QIcon | fromTheme (const QString &name, const QIcon &fallback) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the QIcon corresponding to name in the \l{themeName()}{current icon theme}. | |
static bool | hasThemeIcon (const QString &name) |
static QIcon | fromTheme (ThemeIcon icon) |
static QIcon | fromTheme (ThemeIcon icon, const QIcon &fallback) |
static bool | hasThemeIcon (ThemeIcon icon) |
static QStringList | themeSearchPaths () |
static void | setThemeSearchPaths (const QStringList &searchpath) |
static QStringList | fallbackSearchPaths () |
static void | setFallbackSearchPaths (const QStringList &paths) |
static QString | themeName () |
static void | setThemeName (const QString &path) |
static QString | fallbackThemeName () |
static void | setFallbackThemeName (const QString &name) |
Friends | |
Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &, const QIcon &) |
Q_GUI_EXPORT QDataStream & | operator>> (QDataStream &, QIcon &) |
Related Symbols | |
(Note that these are not member symbols.) | |
QDataStream & | operator<< (QDataStream &stream, const QIcon &icon) |
QDataStream & | operator>> (QDataStream &stream, QIcon &icon) |
The QIcon class provides scalable icons in different modes and states.
\inmodule QtGui
A QIcon can generate smaller, larger, active, and disabled pixmaps from the set of pixmaps it is given. Such pixmaps are used by Qt UI components to show an icon representing a particular action.
enum QIcon::Mode |
This enum type describes the mode for which a pixmap is intended to be used.
The currently defined modes are:
\value Normal Display the pixmap when the user is not interacting with the icon, but the functionality represented by the icon is available. \value Disabled Display the pixmap when the functionality represented by the icon is not available. \value 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. \value Selected Display the pixmap when the item represented by the icon is selected.
Enumerator | |
---|---|
Normal | |
Disabled | |
Active | |
Selected |
enum QIcon::State |
|
strong |
This enum provides access to icons that are provided by most icon theme implementations.
\value AddressBookNew The icon for the action to create a new address book. \value ApplicationExit The icon for exiting an application. \value AppointmentNew The icon for the action to create a new appointment. \value CallStart The icon for initiating or accepting a call. \value CallStop The icon for stopping a current call. \value ContactNew The icon for the action to create a new contact. \value DocumentNew The icon for the action to create a new document. \value DocumentOpen The icon for the action to open a document. \value DocumentOpenRecent The icon for the action to open a document that was recently opened. \value DocumentPageSetup The icon for the {page setup} action. \value DocumentPrint The icon for the {print} action. \value DocumentPrintPreview The icon for the {print preview} action. \value DocumentProperties The icon for the action to view the properties of a document. \value DocumentRevert The icon for the action of reverting to a previous version of a document. \value DocumentSave The icon for the {save} action. \value DocumentSaveAs The icon for the {save as} action. \value DocumentSend The icon for the {send} action. \value EditClear The icon for the {clear} action. \value EditCopy The icon for the {copy} action. \value EditCut The icon for the {cut} action. \value EditDelete The icon for the {delete} action. \value EditFind The icon for the {find} action. \value EditPaste The icon for the {paste} action. \value EditRedo The icon for the {redo} action. \value EditSelectAll The icon for the {select all} action. \value EditUndo The icon for the {undo} action. \value FolderNew The icon for creating a new folder. \value FormatIndentLess The icon for the {decrease indent formatting} action. \value FormatIndentMore The icon for the {increase indent formatting} action. \value FormatJustifyCenter The icon for the {center justification formatting} action. \value FormatJustifyFill The icon for the {fill justification formatting} action. \value FormatJustifyLeft The icon for the {left justification formatting} action. \value FormatJustifyRight The icon for the {right justification} action. \value FormatTextDirectionLtr The icon for the {left-to-right text formatting} action. \value FormatTextDirectionRtl The icon for the {right-to-left formatting} action. \value FormatTextBold The icon for the {bold text formatting} action. \value FormatTextItalic The icon for the {italic text formatting} action. \value FormatTextUnderline The icon for the {underlined text formatting} action. \value FormatTextStrikethrough The icon for the {strikethrough text formatting} action. \value GoDown The icon for the {go down in a list} action. \value GoHome The icon for the {go to home location} action. \value GoNext The icon for the {go to the next item in a list} action. \value GoPrevious The icon for the {go to the previous item in a list} action. \value GoUp The icon for the {go up in a list} action. \value HelpAbout The icon for the {About} item in the Help menu. \value HelpFaq The icon for the {FAQ} item in the Help menu. \value InsertImage The icon for the {insert image} action of an application. \value InsertLink The icon for the {insert link} action of an application. \value InsertText The icon for the {insert text} action of an application. \value ListAdd The icon for the {add to list} action. \value ListRemove The icon for the {remove from list} action. \value MailForward The icon for the {forward} action. \value MailMarkImportant The icon for the {mark as important} action. \value MailMarkRead The icon for the {mark as read} action. \value MailMarkUnread The icon for the {mark as unread} action. \value MailMessageNew The icon for the {compose new mail} action. \value MailReplyAll The icon for the {reply to all} action. \value MailReplySender The icon for the {reply to sender} action. \value MailSend The icon for the {send} action. \value MediaEject The icon for the {eject} action of a media player or file manager. \value MediaPlaybackPause The icon for the {pause} action of a media player. \value MediaPlaybackStart The icon for the {start playback} action of a media player. \value MediaPlaybackStop The icon for the {stop} action of a media player. \value MediaRecord The icon for the {record} action of a media application. \value MediaSeekBackward The icon for the {seek backward} action of a media player. \value MediaSeekForward The icon for the {seek forward} action of a media player. \value MediaSkipBackward The icon for the {skip backward} action of a media player. \value MediaSkipForward The icon for the {skip forward} action of a media player. \value ObjectRotateLeft The icon for the {rotate left} action performed on an object. \value ObjectRotateRight The icon for the {rotate right} action performed on an object. \value ProcessStop The icon for the {stop action in applications with} actions that may take a while to process, such as web page loading in a browser. \value SystemLockScreen The icon for the {lock screen} action. \value SystemLogOut The icon for the {log out} action. \value SystemSearch The icon for the {search} action. \value SystemReboot The icon for the {reboot} action. \value SystemShutdown The icon for the {shutdown} action. \value ToolsCheckSpelling The icon for the {check spelling} action. \value ViewFullscreen The icon for the {fullscreen} action. \value ViewRefresh The icon for the {refresh} action. \value ViewRestore The icon for leaving the fullscreen view. \value WindowClose The icon for the {close window} action. \value WindowNew The icon for the {new window} action. \value ZoomFitBest The icon for the {best fit} action. \value ZoomIn The icon for the {zoom in} action. \value ZoomOut The icon for the {zoom out} action.
\value AudioCard The icon for the audio rendering device. \value AudioInputMicrophone The icon for the microphone audio input device. \value Battery The icon for the system battery device. \value CameraPhoto The icon for a digital still camera devices. \value CameraVideo The icon for a video camera device. \value CameraWeb The icon for a web camera device. \value Computer The icon for the computing device as a whole. \value DriveHarddisk The icon for hard disk drives. \value DriveOptical The icon for optical media drives such as CD and DVD. \value InputGaming The icon for the gaming input device. \value InputKeyboard The icon for the keyboard input device. \value InputMouse The icon for the mousing input device. \value InputTablet The icon for graphics tablet input devices. \value MediaFlash The icon for flash media, such as a memory stick. \value MediaOptical The icon for physical optical media such as CD and DVD. \value MediaTape The icon for generic physical tape media. \value MultimediaPlayer The icon for generic multimedia playing devices. \value NetworkWired The icon for wired network connections. \value NetworkWireless The icon for wireless network connections. \value Phone The icon for phone devices. \value Printer The icon for a printer device. \value Scanner The icon for a scanner device. \value VideoDisplay The icon for the monitor that video gets displayed on.
\value AppointmentMissed The icon for when an appointment was missed. \value AppointmentSoon The icon for when an appointment will occur soon. \value AudioVolumeHigh The icon used to indicate high audio volume. \value AudioVolumeLow The icon used to indicate low audio volume. \value AudioVolumeMedium The icon used to indicate medium audio volume. \value AudioVolumeMuted The icon used to indicate the muted state for audio playback. \value BatteryCaution The icon used when the battery is below 40%. \value BatteryLow The icon used when the battery is below 20%. \value DialogError The icon used when a dialog is opened to explain an error condition to the user. \value DialogInformation The icon used when a dialog is opened to give information to the user that may be pertinent to the requested action. \value DialogPassword The icon used when a dialog requesting the authentication credentials for a user is opened. \value DialogQuestion The icon used when a dialog is opened to ask a simple question to the user. \value DialogWarning The icon used when a dialog is opened to warn the user of impending issues with the requested action. \value FolderDragAccept The icon used for a folder while an acceptable object is being dragged onto it. \value FolderOpen The icon used for folders, while their contents are being displayed within the same window. \value FolderVisiting The icon used for folders, while their contents are being displayed in another window. \value ImageLoading The icon used while another image is being loaded. \value ImageMissing The icon used when another image could not be loaded. \value MailAttachment The icon for a message that contains attachments. \value MailUnread The icon for an unread message. \value MailRead The icon for a read message. \value MailReplied The icon for a message that has been replied to. \value MediaPlaylistRepeat The icon for the repeat mode of a media player. \value MediaPlaylistShuffle The icon for the shuffle mode of a media player. \value NetworkOffline The icon used to indicate that the device is not connected to the network. \value PrinterPrinting The icon used while a print job is successfully being spooled to a printing device. \value SecurityHigh The icon used to indicate that the security level of an item is known to be high. \value SecurityLow The icon used to indicate that the security level of an item is known to be low. \value SoftwareUpdateAvailable The icon used to indicate that an update is available. \value SoftwareUpdateUrgent The icon used to indicate that an urgent update is available. \value SyncError The icon used when an error occurs while attempting to synchronize data across devices. \value SyncSynchronizing The icon used while data is successfully synchronizing across devices. \value UserAvailable The icon used to indicate that a user is available. \value UserOffline The icon used to indicate that a user is not available. \value WeatherClear The icon used to indicate that the sky is clear. \value WeatherClearNight The icon used to indicate that the sky is clear during the night. \value WeatherFewClouds The icon used to indicate that the sky is partly cloudy. \value WeatherFewCloudsNight The icon used to indicate that the sky is partly cloudy during the night. \value WeatherFog The icon used to indicate that the weather is foggy. \value WeatherShowers The icon used to indicate that rain showers are occurring. \value WeatherSnow The icon used to indicate that snow is falling. \value WeatherStorm The icon used to indicate that the weather is stormy.
\omitvalue NThemeIcons
|
noexcept |
Constructs a null icon.
Definition at line 692 of file qicon.cpp.
Referenced by fromTheme().
QIcon::QIcon | ( | const QPixmap & | pixmap | ) |
Constructs an icon from a pixmap.
Definition at line 700 of file qicon.cpp.
References addPixmap(), and pixmap.
QIcon::QIcon | ( | const QIcon & | other | ) |
Constructs a copy of other.
This is very fast.
Definition at line 709 of file qicon.cpp.
References QBasicAtomicInteger< T >::ref(), and QIconPrivate::ref.
|
inlinenoexcept |
|
explicit |
Constructs an icon from the file with the given fileName.
The file will be loaded on demand.
If fileName contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.
The file name can refer to an actual file on disk or to one of the application's embedded resources. See the \l{resources.html}{Resource System} overview for details on how to embed images and other resource files in the application's executable.
Use the QImageReader::supportedImageFormats() and QImageWriter::supportedImageFormats() functions to retrieve a complete list of the supported file formats.
Definition at line 741 of file qicon.cpp.
References addFile(), and fileName.
|
explicit |
QIcon::~QIcon | ( | ) |
Destroys the icon.
Definition at line 760 of file qicon.cpp.
References QBasicAtomicInteger< T >::deref(), and QIconPrivate::ref.
Returns the actual size of the icon for the requested size, mode, and state.
The result might be smaller than requested, but never larger. The returned size is in device-independent pixels (This is relevant for high-dpi pixmaps.)
Definition at line 924 of file qicon.cpp.
References actualSize(), QIconEngine::actualSize(), QIconPrivate::engine, QIconPrivate::pixmapDevicePixelRatio(), qApp, and state.
Referenced by actualSize(), QIconLoaderEngine::actualSize(), createHIcon(), QFontFamilyDelegate::paint(), QCommandLinkButton::paintEvent(), QItemDelegate::rect(), QWindowsSystemTrayIcon::showMessage(), QDockWidgetTitleButton::sizeHint(), QMacStyle::subElementRect(), QCommonStyle::subElementRect(), QQC2::QMacStylePrivate::tabLayout(), and QQC2::QCommonStylePrivate::tabLayout().
void QIcon::addFile | ( | const QString & | fileName, |
const QSize & | size = QSize(), | ||
Mode | mode = Normal, | ||
State | state = Off ) |
Adds an image from the file with the given fileName to the icon, as a specialization for size, mode and state.
The file will be loaded on demand. Note: custom icon engines are free to ignore additionally added pixmaps.
If fileName contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.
The file name can refer to an actual file on disk or to one of the application's embedded resources. See the \l{resources.html}{Resource System} overview for details on how to embed images and other resource files in the application's executable.
Use the QImageReader::supportedImageFormats() and QImageWriter::supportedImageFormats() functions to retrieve a complete list of the supported file formats.
If a high resolution version of the image exists (identified by the suffix @2x
on the base name), it is automatically loaded and added with the {device pixel ratio} set to a value of 2. This can be disabled by setting the environment variable QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING
(see QImageReader).
Definition at line 1111 of file qicon.cpp.
References QIconEngine::addFile(), detach(), QIconPrivate::engine, engine, fileName, iconEngineFromSuffix(), info, QString::isEmpty(), QMimeDatabase::mimeTypeForFile(), QMimeType::preferredSuffix, qApp, qt_findAtNxFile(), and state.
Referenced by QIcon(), QCommonStylePrivate::iconFromMacTheme(), QCommonStylePrivate::iconFromResourceTheme(), qt_setupActionIcon(), and QQC2::QCommonStyle::standardIcon().
Adds pixmap to the icon, as a specialization for mode and state.
Custom icon engines are free to ignore additionally added pixmaps.
Definition at line 1058 of file qicon.cpp.
References QIconEngine::addPixmap(), detach(), QIconPrivate::engine, pixmap, and state.
Referenced by QIcon(), QAbstractFileIconProviderPrivate::getPlatformThemeIcon(), QCommonStylePrivate::iconFromApplicationTheme(), QCommonStylePrivate::iconFromMacTheme(), QCommonStylePrivate::iconFromResourceTheme(), QCommonStylePrivate::iconFromWindowsTheme(), QCss::Declaration::iconValue(), QQC2::QCommonStyle::standardIcon(), and QCommonStyle::standardIcon().
Returns a list of available icon sizes for the specified mode and state.
Definition at line 1142 of file qicon.cpp.
References QIconEngine::availableSizes(), QIconPrivate::engine, and state.
Referenced by QIconLoaderEngine::availableSizes(), fromTheme(), QXcbWindow::setWindowIcon(), and QDBusTrayIcon::updateIcon().
qint64 QIcon::cacheKey | ( | ) | const |
Returns a number that identifies the contents of this QIcon object.
Distinct QIcon objects can have the same key if they refer to the same contents.
The cacheKey() will change when the icon is altered via addPixmap() or addFile().
Cache keys are mostly useful in conjunction with caching.
Definition at line 817 of file qicon.cpp.
References QIconPrivate::detach_no, and QIconPrivate::serialNum.
Referenced by QQC2::QWindowsXPStyle::drawControl(), QWindowsVistaStyle::drawControl(), QWindowsMenuItem::setIcon(), QMacStyle::subElementRect(), and QCommonStyle::subElementRect().
|
inline |
Definition at line 266 of file qicon.h.
References d.
Referenced by ScalableEntry::pixmap().
void QIcon::detach | ( | ) |
Definition at line 1031 of file qicon.cpp.
References QIconEngine::clone(), QBasicAtomicInteger< T >::deref(), QIconPrivate::detach_no, QIconPrivate::engine, QIconEngine::isNull(), QBasicAtomicInteger< T >::loadRelaxed(), and QIconPrivate::ref.
Referenced by addFile(), addPixmap(), and setIsMask().
|
static |
Returns the fallback search paths for icons.
The fallback search paths are consulted for standalone icon files if the \l{themeName()}{current icon theme} or \l{fallbackThemeName()}{fallback icon theme} do not provide results for an icon lookup.
If not set, the fallback search paths will be defined by the platform.
Definition at line 1211 of file qicon.cpp.
References QIconLoader::instance().
Referenced by src_gui_image_qicon::wrapper2().
|
static |
Returns the name of the fallback icon theme.
If not set, the fallback icon theme will be defined by the platform.
Definition at line 1291 of file qicon.cpp.
References QIconLoader::instance().
Referenced by QtWaylandClient::getIconSvg().
Returns the QIcon corresponding to name in the \l{themeName()}{current icon theme}.
If the current theme does not provide an icon for name, the \l{fallbackThemeName()}{fallback icon theme} is consulted, before falling back to looking up standalone icon files in the \l{QIcon::fallbackSearchPaths()}{fallback icon search path}. Finally, the platform's native icon library is consulted.
To fetch an icon from the current icon theme:
If an \l{themeName()}{icon theme} has not been explicitly set via setThemeName() a platform defined icon theme will be used.
Definition at line 1342 of file qicon.cpp.
References QIcon(), icon, and QDir::isAbsolutePath().
Referenced by availableXdgFileIconSizes(), QGuiApplicationPrivate::createPlatformIntegration(), fromTheme(), fromTheme(), fromTheme(), QAbstractFileIconProviderPrivate::getIconThemeIcon(), QAbstractFileIconProviderPrivate::getIconThemeIcon(), hasThemeIcon(), QCommonStylePrivate::iconFromApplicationTheme(), qt_setupActionIcon(), QtWaylandClient::renderButtonIcon(), setActionIcon(), QQC2::QCommonStyle::standardIcon(), QQC2::QCommonStyle::standardPixmap(), QQuickLabsPlatformIconLoader::toQIcon(), and src_gui_image_qicon::wrapper1().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the QIcon corresponding to name in the \l{themeName()}{current icon theme}.
If the current theme does not provide an icon for name, the \l{fallbackThemeName()}{fallback icon theme} is consulted, before falling back to looking up standalone icon files in the \l{QIcon::fallbackSearchPaths()}{fallback icon search path}. Finally, the platform's native icon library is consulted.
If no icon is found fallback is returned.
This is useful to provide a guaranteed fallback, regardless of whether the current set of icon themes and fallbacks paths support the requested icon.
For example:
Definition at line 1380 of file qicon.cpp.
References availableSizes(), fromTheme(), icon, QList< T >::isEmpty(), and isNull().
|
static |
Definition at line 1791 of file qicon.cpp.
References fromTheme(), icon, and themeIconName().
|
static |
Returns the QIcon corresponding to icon in the \l{themeName()}{current icon theme}.
If the current theme does not provide an icon for icon, the \l{fallbackThemeName()}{fallback icon theme} is consulted, before falling back to looking up standalone icon files in the \l{QIcon::fallbackSearchPaths()}{fallback icon search path}. Finally, the platform's native icon library is consulted.
If no icon is found and a fallback is provided, fallback is returned. This is useful to provide a guaranteed fallback, regardless of whether the current set of icon themes and fallbacks paths support the requested icon.
If no icon is found and no fallback is provided, a default constructed, empty QIcon is returned.
Definition at line 1796 of file qicon.cpp.
References fromTheme(), icon, and themeIconName().
|
static |
Returns true
if there is an icon available for name in the current icon theme or any of the fallbacks, as described by fromTheme(), otherwise returns false
.
Definition at line 1399 of file qicon.cpp.
References fromTheme(), icon, and name().
Referenced by hasThemeIcon(), and QCommonStylePrivate::iconFromApplicationTheme().
|
static |
Returns true
if there is an icon available for icon in the current icon theme or any of the fallbacks, as described by fromTheme(), otherwise returns false
.
Definition at line 1763 of file qicon.cpp.
References hasThemeIcon(), icon, and themeIconName().
bool QIcon::isDetached | ( | ) | const |
Definition at line 1024 of file qicon.cpp.
References QBasicAtomicInteger< T >::loadRelaxed(), and QIconPrivate::ref.
bool QIcon::isMask | ( | ) | const |
Returns true
if this icon has been marked as a mask image. Certain platforms render mask icons differently (for example, menu icons on \macos).
Definition at line 1825 of file qicon.cpp.
References QIconPrivate::is_mask.
Referenced by setIsMask().
bool QIcon::isNull | ( | ) | const |
Returns true
if the icon is empty; otherwise returns false
.
An icon is empty if it has neither a pixmap nor a filename.
Note: Even a non-null icon might not be able to create valid pixmaps, eg. if the file does not exist or cannot be read.
Definition at line 1017 of file qicon.cpp.
References QIconPrivate::engine, and QIconEngine::isNull().
Referenced by QDBusMenuItem::QDBusMenuItem(), QMenuBarPrivate::calcActionRects(), createHIcon(), QFileSystemModel::data(), QUndoModel::data(), QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QCommonStyle::drawControl(), QMacStyle::drawControl(), QCommonStyle::drawControl(), QWindows11Style::drawControl(), QtAndroidMenu::fillMenuItem(), fromTheme(), QFileIconProviderPrivate::getIcon(), QAbstractFileIconProvider::icon(), QAbstractFileIconProvider::icon(), iconToQXdgDBusImageVector(), QCss::Declaration::iconValue(), QHeaderView::initStyleOptionForIndex(), QComboBox::insertItem(), QtWaylandClient::QWaylandBradientDecoration::paint(), ScalableEntry::pixmap(), qt_aqua_get_known_size(), QQC2_NAMESPACE::qt_aqua_get_known_size(), QHeaderView::sectionSizeFromContents(), setActionIcon(), QTabBar::setTabIcon(), QWidget::setWindowIcon(), QCocoaWindow::setWindowIcon(), QXcbWindow::setWindowIcon(), QQC2::QCommonStyle::sizeFromContents(), QCheckBox::sizeHint(), QRadioButton::sizeHint(), QQC2::QCommonStyle::standardIcon(), QCommonStyle::standardIcon(), QCommonStyle::standardPixmap(), QQC2::QCommonStyle::subElementRect(), QMacStyle::subElementRect(), QCommonStyle::subElementRect(), QQC2::QMacStylePrivate::tabLayout(), QQC2::QCommonStylePrivate::tabLayout(), QTabBar::tabSizeHint(), and QMenuPrivate::updateActionRects().
QString QIcon::name | ( | ) | const |
Returns the name used to create the icon, if available.
Depending on the way the icon was created, it may have an associated name. This is the case for icons created with fromTheme().
Definition at line 1159 of file qicon.cpp.
References QIconPrivate::engine, and QIconEngine::iconName().
Referenced by QDBusMenuItem::QDBusMenuItem(), hasThemeIcon(), and QDBusTrayIcon::updateIcon().
QIcon::operator QVariant | ( | ) | const |
Returns the icon as a QVariant.
Definition at line 799 of file qicon.cpp.
References QVariant::fromValue().
|
delete |
Assigns the other icon to this icon and returns a reference to this icon.
Move-assigns other to this QIcon instance.
Definition at line 770 of file qicon.cpp.
References QBasicAtomicInteger< T >::deref(), other(), and QIconPrivate::ref.
|
delete |
void QIcon::paint | ( | QPainter * | painter, |
const QRect & | rect, | ||
Qt::Alignment | alignment = Qt::AlignCenter, | ||
Mode | mode = Normal, | ||
State | state = Off ) const |
Uses the painter to paint the icon with specified alignment, required mode, and state into the rectangle rect.
Definition at line 975 of file qicon.cpp.
References QIconEngine::actualSize(), Qt::AlignBottom, alignedRect(), Qt::AlignHCenter, alignment, Qt::AlignRight, Qt::AlignVCenter, QIconPrivate::engine, QPainter::layoutDirection(), QIconEngine::paint(), painter, rect, state, and QGuiApplicationPrivate::visualAlignment().
Referenced by src_gui_image_qicon::MyWidget::drawIcon(), QtWaylandClient::QWaylandBradientDecoration::paint(), and QFontFamilyDelegate::paint().
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
The pixmap might be smaller than requested, but never larger, unless the device-pixel ratio of the returned pixmap is larger than 1.
Definition at line 832 of file qicon.cpp.
References dpr(), pixmap, and state.
Referenced by QDBusMenuItem::QDBusMenuItem(), QErrorMessage::QErrorMessage(), createHIcon(), QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QCommonStyle::drawControl(), QMacStyle::drawControl(), QCommonStyle::drawControl(), QWindows11Style::drawControl(), QtAndroidMenu::fillMenuItem(), if(), QWasmWindow::setWindowIcon(), QXcbWindow::setWindowIcon(), QWindowsSystemTrayIcon::showMessage(), QQC2_NAMESPACE::QMacStyle::standardPixmap(), QMacStyle::standardPixmap(), QCommonStyle::standardPixmap(), QQC2::QWindowsXPStyle::standardPixmap(), QWindowsVistaStyle::standardPixmap(), QQC2::QCommonStyle::subElementRect(), and QCommonStyle::subElementRect().
QPixmap QIcon::pixmap | ( | const QSize & | size, |
qreal | devicePixelRatio, | ||
Mode | mode = Normal, | ||
State | state = Off ) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a pixmap with the requested size, devicePixelRatio, mode, and state, generating one if necessary.
Definition at line 869 of file qicon.cpp.
References QIconPrivate::engine, QIconEngine::pixmap(), pixmap, QIconPrivate::pixmapDevicePixelRatio(), qApp, QIconEngine::scaledPixmap(), and state.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a pixmap of size QSize(extent, extent).
The pixmap might be smaller than requested, but never larger, unless the device-pixel ratio of the returned pixmap is larger than 1.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a pixmap of size QSize(w, h).
The pixmap might be smaller than requested, but never larger, unless the device-pixel ratio of the returned pixmap is larger than 1.
|
static |
Sets the fallback search paths for icons to paths.
The fallback search paths are consulted for standalone icon files if the \l{themeName()}{current icon theme} or \l{fallbackThemeName()}{fallback icon theme} do not provide results for an icon lookup.
For example:
Definition at line 1232 of file qicon.cpp.
References QIconLoader::instance().
Referenced by src_gui_image_qicon::wrapper2().
Sets the fallback icon theme to name.
The fallback icon theme is consulted for icons not provided by the \l{themeName()}{current icon theme}, or if the \l{themeName()} {current icon theme} does not exist.
The name should correspond to theme in the same format as documented by setThemeName(), and will be looked up in themeSearchPaths().
Definition at line 1314 of file qicon.cpp.
References QIconLoader::instance().
void QIcon::setIsMask | ( | bool | isMask | ) |
Sets the current icon theme to name.
The theme will be will be looked up in themeSearchPaths().
At the moment the only supported icon theme format is the \l{Freedesktop Icon Theme Specification}. The name should correspond to a directory name in the themeSearchPath() containing an index.theme
file describing its contents.
Definition at line 1252 of file qicon.cpp.
References QIconLoader::instance().
|
static |
Sets the search paths for icon themes to paths.
The content of paths should follow the theme format documented by setThemeName().
Definition at line 1176 of file qicon.cpp.
References QIconLoader::instance().
Swaps icon other with this icon. This operation is very fast and never fails.
Definition at line 193 of file qicon.h.
References d, other(), and qt_ptr_swap().
|
static |
Returns the name of the current icon theme.
If not set, the current icon theme will be defined by the platform.
Definition at line 1272 of file qicon.cpp.
References QIconLoader::instance().
Referenced by QtWaylandClient::getIconSvg(), QCommonStylePrivate::iconFromApplicationTheme(), QQC2::QCommonStyle::standardIcon(), and QQC2::QCommonStyle::standardPixmap().
|
static |
Returns the search paths for icon themes.
The default search paths will be defined by the platform. All platforms will also have the resource directory {:\icons} as a fallback.
Definition at line 1191 of file qicon.cpp.
References QIconLoader::instance().
Referenced by QIconTheme::QIconTheme(), and QtWaylandClient::getIconSvg().
|
friend |
|
related |
|
friend |
|
related |