QtMac Namespace | Qt Mac Extras 5.9

Qt 5.9 | Qt Mac Extras | QtMac Namespace

Qt 5.9.9 Reference Documentation

# QtMac Namespace

The QtMac namespace contains miscellaneous functionality specific to the macOS and iOS operating systems. More...

Header: | #include <QtMac>
qmake: | QT += macextras
Since: | Qt 5.2

- Obsolete members

## Functions

QString | badgeLabelText()
CGContextRef | currentCGContext()
QPixmap | fromCGImageRef(CGImageRef image)
bool | isMainWindow(QWindow *window)
void | setBadgeLabelText(const QString &text)
CGImageRef | toCGImageRef(const QPixmap &pixmap)
NSImage * | toNSImage(const QPixmap &pixmap)

## Detailed Description

The QtMac namespace contains miscellaneous functionality specific to the macOS and iOS operating systems.

## Function Documentation

### QString QtMac::badgeLabelText()

Returns the text of the application icon a.k.a badge.

See also setBadgeLabelText().

### CGContextRef QtMac::currentCGContext()

Returns the current CoreGraphics context.

### QPixmap QtMac::fromCGImageRef(CGImageRef image)

Returns a QPixmap that is equivalent to the given image.

This function is not available in Qt 5.x until 5.0.2 and will return a null pixmap in earlier versions.

See also toCGImageRef() and Pixmap Conversion.

### bool QtMac::isMainWindow(QWindow *window)

Returns whether the given QWindow window is the application's main window

### void QtMac::setBadgeLabelText(const QString &text)

Sets the text shown on the application icon a.k.a badge.

This is generally used with numbers (e.g. number of unread emails); it can also show a string.

See also badgeLabelText().

### CGImageRef QtMac::toCGImageRef(const QPixmap &pixmap)

Creates a `CGImageRef` equivalent to the QPixmap pixmap. Returns the `CGImageRef` handle.

It is the caller's responsibility to release the `CGImageRef` data after use.

This function is not available in Qt 5.x until 5.0.2 and will return NULL in earlier versions.

See also fromCGImageRef().

### NSImage *QtMac::toNSImage(const QPixmap &pixmap)

Creates an `NSImage` equivalent to the QPixmap pixmap. Returns the `NSImage` handle.

It is the caller's responsibility to release the `NSImage` data after use.