[PyQt] QXmlQuery.evaluate() does'nt accept QString parameter?
David Boddie
dboddie at trolltech.com
Tue Mar 23 17:05:22 GMT 2010
On Tue Mar 23 15:52:22 GMT 2010, Phil Thompson wrote:
> On Tue, 23 Mar 2010 16:34:39 +0100, Olivier Fournier
>
> <o.fournier at perigord.com> wrote:
> >
> > I would like to use the overloaded function QXmlQuery.evaluateTo (self,
> > QString).
[...]
> Mainly laziness on my part. I need to write some handwritten code to deal
> with immutable strings. I'll add...
>
> QXmlQuery.evaluateToString() -> str
>
> ...to tonight's snapshot. None will be returned if the evaluation fails.
I also ran into this recently, but just worked around it by using a QBuffer
to collect data for use in a QByteArray. Since the QXmlQuery writes its
results encoded as UTF-8, you can then create a QString from the QByteArray.
array = QByteArray()
buf = QBuffer(array)
buf.open(QIODevice.WriteOnly)
if query.isValid():
if query.evaluateTo(buf):
results = QString.fromUtf8(array)
print results
buf.close()
David
More information about the PyQt
mailing list