Qt 覆盖文本输入框中tab键的默认功能
作者:互联网
1.新建类TextEdit继承自QTextEdit;
2.重写event事件;
3.判断tab键按下,return false;
TextEdit::TextEdit(QWidget* paernt) : QTextEdit(parent) { } bool TextEdit::event(QEvent* event) { if(event->type() == QEvent::KeyPress) { QKeyEvent* keyEvent = (QKeyEvent*)event; if(keyEvent->key() == Qt::Key_Tab) { return false; } } return QTextEdit::event(event); }
标签:return,Qt,输入框,QTextEdit,TextEdit,tab,false,event 来源: https://www.cnblogs.com/tingtaishou/p/14960525.html