[Qt-interest] Force enter to default button rather than textEdit?
Israel Brewster
israel at frontierflying.com
Thu Sep 15 18:22:47 CEST 2011
Perfect. And I don't even need to subclass QPlainTextEdit. Thanks!
On Sep 14, 2011, at 5:24 PM, Syam Krishnan wrote:
> On 09/15/2011 05:30 AM, Israel Brewster wrote:
>> I have a window with a QPlaintextEdit and a button (among other
>> things). The QPlainTextEdit gets the focus by default, which I want
>> (so you can just type in it). However, when return is pressed, rather
>> than entering a new line in the QPlainTextEdit, I want it to activate
>> the button (which is set to default). I have successfully gotten the
>> QPlainTextEdit to ignore the enter key by overriding the keyPressEvent
>> function, but even so the button isn't picking up on it. I would use a
>> QlineEdit, but I want to be able to display more text than the width
>> alone allows. How can I make this work? Thanks.
>
> Try using QObject::installEventFilter().
> You can install an event filter on the text edit to filter out the
> key-press event for enter key. When such an event happens, you can call
> the slot that's connected to your default button (so that you'll get the
> same behaviour as clicking on the button).
>
>
> Syam
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
-----------------------------------------------
Israel Brewster
Computer Support Technician II
Era Alaska
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x7293
-----------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Israel Brewster.vcf
Type: text/directory
Size: 417 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110915/e1e0d37b/attachment.bin
-------------- next part --------------
More information about the Qt-interest-old
mailing list