[PyQt] A quick question about Return in a text edit
Evan Driscoll
driscoll at cs.wisc.edu
Mon Dec 3 23:56:12 GMT 2012
I want to make a UI that carries out an action when the user presses
return (think like in Pidgin), and I have a couple questions about how
to do this. I've dabbled a very small amount but I'm basically a (Py)Qt
newb.
From what I can tell, I want to use a QPlainTextEdit. I don't think a
QLineEdit will work because I will sometimes need multiple lines, but
they'll arise in ways other than the user pressing enter. (Again, think
about Pidgin: enter sends a message, shift-enter adds a newline.)
Looking at the signals that are available, I don't see one that says
what key has been pressed. I might be able connect a slot to
textChanged() then do something like figure out what the cursor is and
then look at the preceding character or something like that, but it
seems much better to create a subclass of QPlainTextEdit and override
the keyPressEvent() (or maybe keyReleaseEvent()?) function.
Does this all seem reasonable, or am I missing a better approach?
Evan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 554 bytes
Desc: OpenPGP digital signature
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20121203/883cb9dc/attachment.pgp>
More information about the PyQt
mailing list