[PyQt] how to get text from QTextEdit document

Paulino paulino1 at sapo.pt
Thu Apr 26 00:12:15 BST 2007


Hi,

I want to get the text from a QTextEdit widget into a list, to parse and 
store in a database

I found this solution, but I think there is a cleaner way of doing it


    def Imprimir(self):
        doc = self.texto.document()
        block = doc.begin()
        lines = [ block.text() ]
        for i in range( 1, doc.blockCount() ):
            block = block.next()
            lines.append( block.text() )

where :
self.texto = QtGui.QTextEdit(self.widget)


Paulino


More information about the PyQt mailing list