[PyQt] MIMEdata and QVariant class problem

Phil Thompson phil at riverbankcomputing.com
Fri Apr 2 12:21:18 BST 2010


On Fri, 2 Apr 2010 15:23:31 +0530, Anshul Jain <aj.phoenixter at gmail.com>
wrote:
> Hello,
> 
> I have been trying to do drag and drop of icons using MIMEdata class. in
my
> code I have written:
> 
> image= event.mimeData().imageData().  Qt returns a QVariant type value
> after
> executing this statement *(
> http://doc.qt.nokia.com/qt-maemo-4.6/qmimedata.html#imageData*). Thus
image
> is a QVariant.
> 
> 
> Now to get the imageData as QImage i need to use QVariant.value<QImage>()
>  function like one below:
> 
> img= QtGui.QImage()
> img= image.value<QImage>()
> 
> Here's the description:
>
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qvariant.html#qVariantValue
> 
> 
> But the problem is that whenever I run this I get the following error:
> 
> img= image.value<QtGui.QImage>()
> AttributeError: 'QVariant' object has no attribute 'value'
> 
> 
> Please tell me what is the reason for this error. kindly help me on this.

Python isn't C++ - try...

img = QImage(image)

Phil


More information about the PyQt mailing list