Skip to content

PythonQt.QtGui.QIcon · declarations 001

Back to PythonQt.QtGui.QIcon

Active instance-attribute

Active: Any

Disabled instance-attribute

Disabled: Any

Off instance-attribute

Off: Any

On instance-attribute

On: Any

Selected instance-attribute

Selected: Any

actualSize

actualSize(window: Any, size: Any, mode: Any, state: Any) -> Any

X.actualSize(window, size, mode, state) -> PythonQt.QtCore.QSize

Supplemental documentation: Qt 5 reference:

QSize QIcon::actualSize(const QSize \&size, QIcon::Mode mode \= Normal, QIcon::State state \= Off) const

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.)

See also pixmap() and paint().

QSize QIcon::actualSize(QWindow *window, const QSize \&size, QIcon::Mode mode \= Normal, QIcon::State state \= Off) const

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

The pixmap can be smaller than the requested size. The returned size is in device-independent pixels (This is relevant for high-dpi pixmaps.)

This function was introduced in Qt 5.1.

See also actualSize(), pixmap(), and paint().

Upstream PySide2 reference signatures (binding differences may apply):

actualSize(self, size: PySide2.QtCore.QSize, mode: PySide2.QtGui.QIcon.Mode=..., state: PySide2.QtGui.QIcon.State=...) -> PySide2.QtCore.QSize
actualSize(self, window: PySide2.QtGui.QWindow, size: PySide2.QtCore.QSize, mode: PySide2.QtGui.QIcon.Mode=..., state: PySide2.QtGui.QIcon.State=...) -> PySide2.QtCore.QSize

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#actualSize

addFile

addFile(fileName: str, size: Any, mode: Any, state: Any) -> None

X.addFile(fileName, size, mode, state)

Supplemental documentation: Qt 5 reference:

void QIcon::addFile(const QString \&fileName, const QSize \&size \= QSize(), QIcon::Mode mode \= Normal, QIcon::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 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).

Note: When you add a non-empty filename to a QIcon, the icon becomes non-null, even if the file doesn't exist or points to a corrupt file.

See also addPixmap() and QPixmap::devicePixelRatio().

Upstream PySide2 reference signatures (binding differences may apply):

addFile(self, fileName: str, size: PySide2.QtCore.QSize=..., mode: PySide2.QtGui.QIcon.Mode=..., state: PySide2.QtGui.QIcon.State=...) -> None

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#addFile

addPixmap

addPixmap(pixmap: Any, mode: Any, state: Any) -> None

X.addPixmap(pixmap, mode, state)

Supplemental documentation: Qt 5 reference:

void QIcon::addPixmap(const QPixmap \&pixmap, QIcon::Mode mode \= Normal, QIcon::State state \= Off)

Adds pixmap to the icon, as a specialization for mode and state.

Custom icon engines are free to ignore additionally added pixmaps.

See also addFile().

Upstream PySide2 reference signatures (binding differences may apply):

addPixmap(self, pixmap: PySide2.QtGui.QPixmap, mode: PySide2.QtGui.QIcon.Mode=..., state: PySide2.QtGui.QIcon.State=...) -> None

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#addPixmap

availableSizes

availableSizes(mode: Any, state: Any) -> tuple

X.availableSizes(mode, state) -> tuple

Supplemental documentation: Qt 5 reference:

QList\<QSize> QIcon::availableSizes(QIcon::Mode mode \= Normal, QIcon::State state \= Off) const

Returns a list of available icon sizes for the specified mode and state.

This function was introduced in Qt 4.5.

Upstream PySide2 reference signatures (binding differences may apply):

availableSizes(self, mode: PySide2.QtGui.QIcon.Mode=..., state: PySide2.QtGui.QIcon.State=...) -> typing.List[PySide2.QtCore.QSize]

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#availableSizes

cacheKey

cacheKey() -> int

X.cacheKey() -> int

Supplemental documentation: Qt 5 reference:

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.

This function was introduced in Qt 4.3.

See also QPixmap::cacheKey().

Upstream PySide2 reference signatures (binding differences may apply):

cacheKey(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#cacheKey

fromTheme

fromTheme(name: str, fallback: Any) -> Any

X.fromTheme(name, fallback) -> PythonQt.QtGui.QIcon

Supplemental documentation: Qt 5 reference:

[static] QIcon QIcon::fromTheme(const QString \&name)

Returns the QIcon corresponding to name in the current icon theme.

The latest version of the freedesktop icon specification and naming specification can be obtained here:

To fetch an icon from the current icon theme:

    QIcon undoicon = QIcon::fromTheme("edit-undo");

Note: By default, only X11 will support themed icons. In order to use themed icons on Mac and Windows, you will have to bundle a compliant theme in one of your themeSearchPaths() and set the appropriate themeName().

Note: Qt will make use of GTK's icon-theme.cache if present to speed up the lookup. These caches can be generated using gtk-update-icon-cache: https://developer.gnome.org/gtk3/stable/gtk-update-icon-cache.html.

Note: If an icon can't be found in the current theme, then it will be searched in fallbackSearchPaths() as an unthemed icon.

This function was introduced in Qt 4.6.

See also themeName(), setThemeName(), themeSearchPaths(), and fallbackSearchPaths().

[static] QIcon QIcon::fromTheme(const QString \&name, const QIcon \&fallback)

This is an overloaded function.

Returns the QIcon corresponding to name in the current icon theme. If no such icon is found in the current theme fallback is returned instead.

If you want to provide a guaranteed fallback for platforms that do not support theme icons, you can use the second argument:

    QIcon undoicon = QIcon::fromTheme("edit-undo", QIcon(":/undo.png"));

Upstream PySide2 reference signatures (binding differences may apply):

fromTheme(name: str) -> PySide2.QtGui.QIcon
fromTheme(name: str, fallback: PySide2.QtGui.QIcon) -> PySide2.QtGui.QIcon

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#fromTheme

hasThemeIcon

hasThemeIcon(name: str) -> bool

X.hasThemeIcon(name) -> bool

Supplemental documentation: Qt 5 reference:

[static] bool QIcon::hasThemeIcon(const QString \&name)

Returns true if there is an icon available for name in the current icon theme, otherwise returns false.

This function was introduced in Qt 4.6.

See also themeSearchPaths(), fromTheme(), and setThemeName().

Upstream PySide2 reference signatures (binding differences may apply):

hasThemeIcon(name: str) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#hasThemeIcon

isMask

isMask() -> bool

X.isMask() -> bool

Supplemental documentation: Qt 5 reference:

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).

This function was introduced in Qt 5.6.

See also setIsMask().

Upstream PySide2 reference signatures (binding differences may apply):

isMask(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#isMask

isNull

isNull() -> bool

X.isNull() -> bool

Supplemental documentation: Qt 5 reference:

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.

Upstream PySide2 reference signatures (binding differences may apply):

isNull(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#isNull

name

name() -> str

X.name() -> str

Supplemental documentation: Qt 5 reference:

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() or icons using a QIconEngine which supports the QIconEngine::IconNameHook.

This function was introduced in Qt 4.7.

See also fromTheme() and QIconEngine.

Upstream PySide2 reference signatures (binding differences may apply):

name(self) -> str

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#name

paint

paint(painter: Any, x: Any, y: Any, w: Any, h: Any, alignment: Any, mode: Any, state: Any) -> None

X.paint(painter, x, y, w, h, alignment, mode, state)

Supplemental documentation: Qt 5 reference:

void QIcon::paint(QPainter *painter, const QRect \&rect, Qt::Alignment alignment \= Qt::AlignCenter, QIcon::Mode mode \= Normal, QIcon::State state \= Off) const

Uses the painter to paint the icon with specified alignment, required mode, and state into the rectangle rect.

See also actualSize() and pixmap().

void QIcon::paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment \= Qt::AlignCenter, QIcon::Mode mode \= Normal, QIcon::State state \= Off) const

This is an overloaded function.

Paints the icon into the rectangle QRect(x, y, w, h).

Upstream PySide2 reference signatures (binding differences may apply):

paint(self, painter: PySide2.QtGui.QPainter, rect: PySide2.QtCore.QRect, alignment: PySide2.QtCore.Qt.Alignment=..., mode: PySide2.QtGui.QIcon.Mode=..., state: PySide2.QtGui.QIcon.State=...) -> None
paint(self, painter: PySide2.QtGui.QPainter, x: int, y: int, w: int, h: int, alignment: PySide2.QtCore.Qt.Alignment=..., mode: PySide2.QtGui.QIcon.Mode=..., state: PySide2.QtGui.QIcon.State=...) -> None

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#paint

pixmap

pixmap(window: Any, size: Any, mode: Any, state: Any) -> Any

X.pixmap(window, size, mode, state) -> PythonQt.QtGui.QPixmap

Supplemental documentation: Qt 5 reference:

QPixmap QIcon::pixmap(const QSize \&size, QIcon::Mode mode \= Normal, QIcon::State state \= Off) const

Returns a pixmap with the requested size, mode, and state, generating one if necessary. The pixmap might be smaller than requested, but never larger.

Setting the Qt::AA_UseHighDpiPixmaps application attribute enables this function to return pixmaps that are larger than the requested size. Such images will have a devicePixelRatio larger than 1.

See also actualSize() and paint().

QPixmap QIcon::pixmap(int w, int h, QIcon::Mode mode \= Normal, QIcon::State state \= Off) const

This is an overloaded function.

Returns a pixmap of size QSize(w, h). The pixmap might be smaller than requested, but never larger.

Setting the Qt::AA_UseHighDpiPixmaps application attribute enables this function to return pixmaps that are larger than the requested size. Such images will have a devicePixelRatio larger than 1.

QPixmap QIcon::pixmap(int extent, QIcon::Mode mode \= Normal, QIcon::State state \= Off) const

This is an overloaded function.

Returns a pixmap of size QSize(extent, extent). The pixmap might be smaller than requested, but never larger.

Setting the Qt::AA_UseHighDpiPixmaps application attribute enables this function to return pixmaps that are larger than the requested size. Such images will have a devicePixelRatio larger than 1.

QPixmap QIcon::pixmap(QWindow *window, const QSize \&size, QIcon::Mode mode \= Normal, QIcon::State state \= Off) const

Returns a pixmap with the requested window size, mode, and state, generating one if necessary.

The pixmap can be smaller than the requested size. If window is on a high-dpi display the pixmap can be larger. In that case it will have a devicePixelRatio larger than 1.

This function was introduced in Qt 5.1.

See also actualSize() and paint().

Upstream PySide2 reference signatures (binding differences may apply):

pixmap(self, extent: int, mode: PySide2.QtGui.QIcon.Mode=..., state: PySide2.QtGui.QIcon.State=...) -> PySide2.QtGui.QPixmap
pixmap(self, size: PySide2.QtCore.QSize, mode: PySide2.QtGui.QIcon.Mode=..., state: PySide2.QtGui.QIcon.State=...) -> PySide2.QtGui.QPixmap
pixmap(self, w: int, h: int, mode: PySide2.QtGui.QIcon.Mode=..., state: PySide2.QtGui.QIcon.State=...) -> PySide2.QtGui.QPixmap
pixmap(self, window: PySide2.QtGui.QWindow, size: PySide2.QtCore.QSize, mode: PySide2.QtGui.QIcon.Mode=..., state: PySide2.QtGui.QIcon.State=...) -> PySide2.QtGui.QPixmap

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#pixmap

setIsMask

setIsMask(isMask: bool) -> None

X.setIsMask(isMask)

Supplemental documentation: Qt 5 reference:

void QIcon::setIsMask(bool isMask)

Indicate that this icon is a mask image(boolean isMask), and hence can potentially be modified based on where it's displayed.

This function was introduced in Qt 5.6.

See also isMask().

Upstream PySide2 reference signatures (binding differences may apply):

setIsMask(self, isMask: bool) -> None

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#setIsMask

setThemeName

setThemeName(path: str) -> None

X.setThemeName(path)

Supplemental documentation: Qt 5 reference:

[static] void QIcon::setThemeName(const QString \&name)

Sets the current icon theme to name.

The name should correspond to a directory name in the themeSearchPath() containing an index.theme file describing its contents.

This function was introduced in Qt 4.6.

See also themeSearchPaths() and themeName().

Upstream PySide2 reference signatures (binding differences may apply):

setThemeName(path: str) -> None

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#setThemeName

setThemeSearchPaths

setThemeSearchPaths(searchpath: Any) -> None

X.setThemeSearchPaths(searchpath)

Supplemental documentation: Qt 5 reference:

[static] void QIcon::setThemeSearchPaths(const QStringList \&paths)

Sets the search paths for icon themes to paths.

This function was introduced in Qt 4.6.

See also themeSearchPaths(), fromTheme(), and setThemeName().

Upstream PySide2 reference signatures (binding differences may apply):

setThemeSearchPaths(searchpath: typing.Sequence[str]) -> None

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#setThemeSearchPaths

swap

swap(other: Any) -> None

X.swap(other)

Supplemental documentation: Qt 5 reference:

void QIcon::swap(QIcon \&other)

Swaps icon other with this icon. This operation is very fast and never fails.

This function was introduced in Qt 4.8.

Upstream PySide2 reference signatures (binding differences may apply):

swap(self, other: PySide2.QtGui.QIcon) -> None

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#swap

themeName

themeName() -> str

X.themeName() -> str

Supplemental documentation: Qt 5 reference:

[static] QString QIcon::themeName()

Returns the name of the current icon theme.

On X11, the current icon theme depends on your desktop settings. On other platforms it is not set by default.

This function was introduced in Qt 4.6.

See also setThemeName(), themeSearchPaths(), fromTheme(), and hasThemeIcon().

Upstream PySide2 reference signatures (binding differences may apply):

themeName() -> str

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#themeName

themeSearchPaths

themeSearchPaths() -> tuple

X.themeSearchPaths() -> tuple

Supplemental documentation: Qt 5 reference:

[static] QStringList QIcon::themeSearchPaths()

Returns the search paths for icon themes.

The default value will depend on the platform:

On X11, the search path will use the XDG_DATA_DIRS environment variable if available.

By default all platforms will have the resource directory :\icons as a fallback. You can use "rcc -project" to generate a resource file from your icon theme.

This function was introduced in Qt 4.6.

See also setThemeSearchPaths(), fromTheme(), and setThemeName().

Upstream PySide2 reference signatures (binding differences may apply):

themeSearchPaths() -> typing.List[str]

Source: https://doc.qt.io/archives/qt-5.15/qicon.html#themeSearchPaths