Obsolete Members for QPixmap

以下成員源於類 QPixmap 已過時。 提供它們是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它們。

公共函數

(obsolete) QPixmap alphaChannel () const
(obsolete) int serialNumber () const
(obsolete) void setAlphaChannel (const QPixmap & alphaChannel )

成員函數文檔編製

QPixmap QPixmap:: alphaChannel () const

Returns the alpha channel of the pixmap as a new grayscale QPixmap in which each pixel's red, green, and blue values are given the alpha value of the original pixmap. The color depth of the returned pixmap is the system depth on X11 and 8-bit on Windows and Mac OS X.

You can use this function while debugging to get a visible image of the alpha channel. If the pixmap doesn't have an alpha channel, i.e., the alpha channel's value for all pixels equals 0xff), a null pixmap is returned. You can check this with the isNull() 函數。

舉例說明:

        pixmap = QPixmap(100, 100);
        pixmap.fill(Qt::transparent);
        QRadialGradient gradient(50, 50, 50, 50, 50);
        gradient.setColorAt(0, QColor::fromRgbF(1, 0, 0, 1));
        gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
        QPainter painter(&pixmap);
        painter.fillRect(0, 0, 100, 100, gradient);
        channelImage = pixmap.alphaChannel();
        update();
					

The pixmap and channelImage QPixmaps

警告: This is an expensive operation. The alpha channel of the pixmap is extracted dynamically from the pixeldata. Most usecases of this function are covered by QPainter and compositionModes which will normally execute faster.

另請參閱 setAlphaChannel () 和 像素圖信息 .

int QPixmap:: serialNumber () const

返迴內容標識數對於此 QPixmap 對象。截然不同的 QPixmap objects can only have the same serial number if they refer to the same contents (but they don't have to).

使用 cacheKey () 代替。

警告: The serial number doesn't necessarily change when the pixmap is altered. This means that it may be dangerous to use it as a cache key. For caching pixmaps, we recommend using the QPixmapCache class whenever possible.

void QPixmap:: setAlphaChannel (const QPixmap & alphaChannel )

Sets the alpha channel of this pixmap to the given alphaChannel by converting the alphaChannel into 32 bit and using the intensity of the RGB pixel values.

此函數的效果未定義,當描繪像素圖時。

警告: This is potentially an expensive operation. Most usecases for this function are covered by QPainter and compositionModes which will normally execute faster.

另請參閱 alphaChannel () 和 像素圖變換 .