[Qt-interest] KeyPressEvent hinders eidting the QTextEdit
Samuel Gaist
samuel.gaist at edeltech.ch
Wed Jun 8 18:01:24 CEST 2011
On 8 juin 2011, at 17:04, Sujan Dasmahapatra wrote:
> Dear Friend
> I have a QTextEdit I want to capture the KeyPressEvent and take each of the text user enters through keyboard. Late I want to change the color of those text. But when I reimplement KeyPressEvent() my text edit becomes choked means I am not able to edit anything. Why this is happening I want to be able to write text in the editor. Any suggestion would be highly appreciated. Thanks sujan
>
> Check the code snippet
>
> void CTextEditor::keyPressEvent ( QKeyEvent * e )
> {
> setFocusPolicy(Qt::NoFocus);
> QString text = e->text();
> tree->hlighter->highlightBlock(text);
> }
>
> void CTextEditor::keyPressEvent ( QKeyEvent * e )
> {
> setFocusPolicy(Qt::NoFocus);
> QString text = e->text();
> tree->hlighter->highlightBlock(text);
> }
>
> Just because I reimplemented KeyPressEvent I am not able to enter anything in the editor. Please give some suggestions.
>
>
> Kind Regards,
>
>
> Sujan Dasmahapatra
> Project Leader, Aero Group
> Aero Group
>
> Tel +91 80 66470248
> Mob
> sdh at lmwindpower.com
>
>
> LM Wind Power Blades
> lmwindpower.com
>
> Together we capture the wind to power a cleaner world
>
> This e-mail and any attachments are confidential. If you are not the named or intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Any unauthorized disclosure, use or storage is prohibited and might be unlawful.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
Hello,
Try to call QTextEdit::keyPressEvent before doing your stuff.
Hope this helps
Samuel
More information about the Qt-interest-old
mailing list