Obsolete Members for QPixmapCache

以下成员源于类 QPixmapCache 已过时。 提供它们是为使旧源代码能继续工作。强烈建议不要在新代码中使用它们。

静态公共成员

(obsolete) bool find (const QString & key , QPixmap & pixmap )
(obsolete) QPixmap * find (const QString & key )

成员函数文档编制

[static] bool QPixmapCache:: find (const QString & key , QPixmap & pixmap )

Use bool find(const QString &, QPixmap *) 代替。

[static] QPixmap *QPixmapCache:: find (const QString & key )

这是重载函数。

Returns the pixmap associated with the key in the cache, or null if there is no such pixmap.

警告: If valid, you should copy the pixmap immediately (this is fast). Subsequent insertions into the cache could cause the pointer to become invalid. For this reason, we recommend you use bool find(const QString &, QPixmap *) 代替。

范例:

QPixmap* pp;
QPixmap p;
if ((pp=QPixmapCache::find("my_big_image", pm))) {
    p = *pp;
} else {
    p.load("bigimage.png");
    QPixmapCache::insert("my_big_image", new QPixmap(p));
}
painter->drawPixmap(0, 0, p);