[PyKDE] Converting QStrings to Python strings

Janos Blazi jblazi at gmx.de
Mon May 6 09:03:00 BST 2002


I thought that PyQt would convert QStrings to Python strings automatically,
but this seems not to be true:

---------------------------------------------------------------------------
import sys
from qt import *

app=QApplication(sys.argv)
vbox=QVBox()

edit=QLineEdit(vbox)
ok=QPushButton('Finish',vbox)
QObject.connect(ok,SIGNAL("clicked()"),app,SLOT("quit()"))
vbox.show()

app.exec_loop()
print int(edit.text())
--------------------------------------------------------------------------

In this code I read a string from a QLineEdit and try to convert it to an
integer but this is not possible as the return value edit.text() is a QString.
(I also get a segmentation fault, who knows, why?)

So how can I convert the QString to a Python string?

TIA,
Janos Blazi

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net




More information about the PyQt mailing list