QIcon

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

This class is a JS wrapper around Qt's QIcon class

Example

const { QIcon } = require("@nodegui/nodegui");
const imageUrl = "path/to/png";
const icon = new QIcon(imageUrl);

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

+ new QIcon(): QIcon

Overrides Component.constructor

Returns: QIcon

+ new QIcon(native: NativeElement): QIcon

Overrides Component.constructor

Parameters:

NameType
nativeNativeElement

Returns: QIcon

+ new QIcon(filePath: string): QIcon

Overrides Component.constructor

Parameters:

NameType
filePathstring

Returns: QIcon

+ new QIcon(pixmap: QPixmap): QIcon

Overrides Component.constructor

Parameters:

NameType
pixmapQPixmap

Returns: QIcon

Properties

native

native: NativeElement | null

Inherited from Component.native

Methods

actualSize

actualSize(size: QSize, mode: QIconMode, state: QIconState): QSize

Parameters:

NameTypeDefault
sizeQSizenull
modeQIconModeQIconMode.Normal
stateQIconStateQIconState.Off

Returns: QSize


addFile

addFile(fileName: string, size: QSize, mode: QIconMode, state: QIconState): void

Parameters:

NameTypeDefault
fileNamestring-
sizeQSizenull
modeQIconModeQIconMode.Normal
stateQIconStateQIconState.Off

Returns: void


addPixmap

addPixmap(pixmap: QPixmap, mode: QIconMode, state: QIconState): void

Parameters:

NameTypeDefault
pixmapQPixmap-
modeQIconModeQIconMode.Normal
stateQIconStateQIconState.Off

Returns: void


availableSizes

availableSizes(mode: QIconMode, state: QIconState): QSize[]

Parameters:

NameTypeDefault
modeQIconModeQIconMode.Normal
stateQIconStateQIconState.Off

Returns: QSize[]


cacheKey

cacheKey(): number

Returns: number


isMask

isMask(): boolean

Returns: boolean


isNull

isNull(): boolean

Returns: boolean


name

name(): string

Returns: string


paint

paint(painter: QPainter, x: number, y: number, w: number, h: number, alignment: AlignmentFlag, mode: QIconMode, state: QIconState): void

Parameters:

NameTypeDefault
painterQPainter-
xnumber-
ynumber-
wnumber-
hnumber-
alignmentAlignmentFlagAlignmentFlag.AlignCenter
modeQIconModeQIconMode.Normal
stateQIconStateQIconState.Off

Returns: void


pixmap

pixmap(width: number, height: number, mode: QIconMode, state: QIconState): QPixmap

Parameters:

NameTypeDefault
widthnumber-
heightnumber-
modeQIconModeQIconMode.Normal
stateQIconStateQIconState.Off

Returns: QPixmap


setIsMask

setIsMask(isMask: boolean): void

Parameters:

NameType
isMaskboolean

Returns: void


swap

swap(other: QIcon): void

Parameters:

NameType
otherQIcon

Returns: void


Static fromQVariant

fromQVariant(variant: QVariant): QIcon

Parameters:

NameType
variantQVariant

Returns: QIcon