Meloun
Meloun

Reputation: 15049

pyqt: QTextEdit: save changed text

I am trying to call my function with changed text as parameter.

QtCore.QObject.connect(Ui().textEdit, QtCore.SIGNAL("textChanged()"), lambda mytext = Ui().textProfileDesc.toHtml(): self.myprint(mytext))

But it doesn't work, in mytext is the text before change.

def myprint(self, mytext):
    print "text1",mytext
    print "text2", Ui().textEdit.toHtml()

text1 - text before change, why??

text2 - changed text as expected

Upvotes: 0

Views: 695

Answers (1)

svlasov
svlasov

Reputation: 10456

You connect the signal to textEdit but query the text from textProfileDesc.

Also, I think you don't really need lambda:

Ui().textEdit.textChanged.connect(self.myprint)

Upvotes: 1

Related Questions