[PyQt] Please tell me if I have this straight...
David Cortesi
davecortesi at gmail.com
Sun Aug 7 03:53:39 BST 2011
OK, David Boddie helped clear up my confusion (as did rereading
chapter 1 of "Rapid GUI Programming") -- to get from a QString to
something I can work on in Python it is only necessary to apply
unicode(). Doh! (Facepalm).
BLEEP represents any transformation that the user requires, which is
not in Qt's repertoire, hence can only be implemented by taking the
document away from QPlainTextEdit, doing the work, and putting the
bleeped document back in the widget for display.
docAsTextDoc = myPlainTextEdit.document() # probably just a pointer
docAsQString = docAsTextDoc.toPlainText() # copy? or just pointer?
bleepedDoc = BLEEP( unicode( docAsQString ) ) # data copied both in and out
docAsQString = QString( bleepedDoc ) # probably another copy
docAsTextDoc.setPlainText( docAsQString ) # probably pointer swap?
myPlainTextEdit.setDocument(docAsTextDoc) # probably pointer swap
More information about the PyQt
mailing list