[PyQt] string printing question

Scott Frankel frankel at circlesfx.com
Fri May 15 05:01:42 BST 2009


How does one convert from QString and QBytArray values to plain ascii  
strings for printing?

I would like to print plain ascii text to a file, based on values I  
glean from QLineEdit and QDateEdit fields.  eg:

self.theLineEdit          = QtGui.QLineEdit()
self.theDateEdit          = QtGui.QDateEdit()
lineStr = self.theLineEdit .text()
dateStr = theDateEdit.text()
outfile.write(lineStr)
outfile.write(dateStr)


This yields:

PyQt4.QtCore.QString(u'foo')
PyQt4.QtCore.QByteArray('5/14/09')

When what I want is:

foo
5/14/09

I've tried using toAscii(), toLatin1(), etc., with no change.

Thanks in advance,
Scott




More information about the PyQt mailing list