[Interest] keyPressEvent on subclass of QPlainTextEdit

nus1998 nus1998 at yeah.net
Sun May 6 15:28:08 CEST 2018


It's weired that the same code on another pc (same qt version, but win10x64 professional) works fine. as the widget recevied these keys, so it seems impossible that it's due to some global hot-keys.






At 2018-05-04 08:55:09, "nus1998" <nus1998 at yeah.net> wrote:

Hi All,

I have some questions on keyPressEvent on sub-class of QPlainTextEdit, for the code attached below.
If I press '(', '{', or '[', these keys will be displayed in the edit. qDebug outputs 16777248  (value of Shift) for '(' and '{',  and outputs nothing for '['.
if I press any other key, they will be printed correctly and not displayed in the edit.

What's the problem for that?

my env: Qt 5.6.2 minGW version on win10 x64.

Best regards
Nus



#ifndefTESTEDIT_H
#defineTESTEDIT_H
#include<QPlainTextEdit>
#include<QKeyEvent>
#include<QDebug>


classTestEdit:publicQPlainTextEdit
{
Q_OBJECT
public:
TestEdit(){}
protected:
virtualvoidkeyPressEvent(QKeyEvent*e){qDebug()<<e->key();}
};


#endif//TESTEDIT_H

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180506/5959e47f/attachment.html>


More information about the Interest mailing list