PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 794 - QPixmapCache.find example is wrong
: QPixmapCache.find example is wrong
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: Documentation
: 1.0.0
: PC Linux
: P4 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2011-03-27 22:41 EEST by Petr Viktorin
Modified: 2011-04-01 23:15 EEST (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Viktorin 2011-03-27 22:41:38 EEST
http://www.pyside.org/docs/pyside/PySide/QtGui/QPixmapCache.html#PySide.QtGui.PySide.QtGui.QPixmapCache.find

The example above uses QPixmapCache.find with one argument, but it actually
takes two. Also it's shown returning a QPixmap, but really it returns a bool.

A correct example would be:

key = "my_big_image"
pm = QPixmap()
if not QPixmapCache.find(key, pm):
    pm.load("bigimage.png")
    QPixmapCache.insert(key, pm)
painter.drawPixmap(0, 0, pm)


Alternatively find should be changed to take only the key and return either a
QPixmap or Null, which would be more pythonic...
Comment 1 Hugo Parente Lima 2011-03-28 20:56:40 EEST
Example changed to:

pm = QPixmap()
if not QPixmapCache.find("my_big_image", pm):
    pm.load("bigimage.png")
    QPixmapCache.insert("my_big_image", pm)
painter.drawPixmap(0, 0, pm)

in commit:
pyside/f8bc57c61cfe16232a0aad8fb8eb6ae5d12ca7c9

About your suggestion for QPixmapCache.find(str) => QPixmap/None, I think it's
a valid one, but better to discuss it bit on mailing list then file a new bug
here.
Comment 2 Hugo Parente Lima 2011-04-01 23:15:58 EEST
Closing bug after release of PySide 1.0.1.