Hello everibody
I need get how to overwrite the QKeyEvent, to get the tab behaviour with the enter-return key.
Hello everibody
I need get how to overwrite the QKeyEvent, to get the tab behaviour with the enter-return key.
You could more easily override a QWidget and reimplement its keyPressEvent() or keyReleaseEvent(), catch the Enter Key, then do whatever you want...
Qt Code:
#ifndef KEY_WIDGET_H #define KEY_WIDGET_H #include <QWidget> { public: KeyWidget(); virtual ~KeyWidget(); protected: } #endif //KEY_WIDGET_H #include "keywidget.h" KeyWidget::KeyWidget() {} KeyWidget::~KeyWidget() {} { if(ke->key() == Qt::Key_Return) { //do something... } }To copy to clipboard, switch view to plain text mode
Ok, but how I can use this reimplemented QWidget's function on a desired widget?
either
* derive from the widget and override the method there
* or install an event filter QObject::installEventFilter() (this is the way to go if you need to watch many widgets and esp. if you have to watch widgets that you did/can not implement yourself.
Bookmarks