c++ - Qt Whenever pressed enter in QTextEdit -
whenever pressed enter in qtextedit it'll perform click on login button. somehow causes crash of qtcreator. how can change what'll happen if press enter in qtextedit?
you need subclass qtextedit
, catch event you're interested in overriding appropriate method:
class mytextedit : public qtextedit { q_object public: void mytextedit::keypressevent(qkeyevent *event) { if (event->key() == qt::key_return) { login(); // or rather emit submitted() or along way } else { qtextedit::keypressevent(event); } } };
alternatively, can install event filter on text edit.
Comments
Post a Comment