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