On Thu, May 03, 2012 at 08:15:26AM -0400, Mark Mordeca wrote:
> while(query.next()):
> 
>      idString=str(query.value(0).toString())
> 
>      passwordString=str(query.value(1).toString())
> 
> 
> 
> query.value()  returns a QVariant, so you use .toString() to convert it to
> a QString, then use str to convert the QString to a python string.

One step less, and more sensible behaviour:

query.value(0).toPyObject()

It'll come out as the python native type for the variant, so QString
goes to unicode, etc. Also works for random python classes that
QVariant doesn't know about.

(This should be better documented)
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to