[Qt-interest] Getting QVariant from QPixmap...and a strange operator!
Mandeep Sandhu
mandeepsandhu.chd at gmail.com
Tue Jul 20 07:21:09 CEST 2010
Hi All,
I had a requirement where I need to return a QPixmap as a QVariant (in
the data() function of my custom model).
I have a QCache object which stores the Pixmaps and a key is used to
retrieve them.
I'm using the following code to return the pixmap wrapped in a QVariant:
...
QPixmap *pix = m_cache.object(key); // The object for this key exists here
return QVariant(*pix);
Is this the correct way of returning the pixmap?
The QPixmap doc mentions an operator which is used for this purpose:
<snip>
QPixmap::operator QVariant () const
Returns the pixmap as a QVariant.
</snip>
I didn't quite understand this! Which "operator" are we talking about
here? Why doesn't it have a return value or is the QVariant the return
value?
Any pointers are appreciated.
Thanks,
-mandeep
More information about the Qt-interest-old
mailing list