[PyKDE] QPixmap from a QVariant?

Jan Ekholm jan.ekholm at smultron.net
Mon Oct 30 20:44:59 GMT 2006


Hi,

While playing with subclassing QItemDelegate using PyQt4 I stumbled upon a 
little thing that I can't seem to figure out, nor do the docs seem to mention 
it.

In the QItemDelegate subclass and in the paint() method I get the QIcon that 
should be used for the decoration role. That's fine, but the QIcon is in a 
QVariant and the QVariant class has no QVariant.toIcon() method, one should 
in C++ use code like:

if (v.canConvert<Qicon>())
     QPixmap p = v.value<QIcon>(v);

How would one do that with PyQt? Any workarounds if it can't be cast to QIcon? 

Best regards,
    Jan Ekholm

-- 
          "Yes, bugger all that." said Nanny. "Let's curse somebody."
                                            -- Terry Pratchett, Wyrd Sisters




More information about the PyQt mailing list