ktextedit.hpp 819 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef KTEXTEDIT_HPP
  2. #define KTEXTEDIT_HPP
  3. #include <QTextEdit>
  4. #include <QDebug>
  5. #include <QKeyEvent>
  6. #include <QtUiPlugin/QDesignerCustomWidgetInterface>
  7. class KTextEdit : public QTextEdit, public QDesignerCustomWidgetInterface {
  8. Q_OBJECT
  9. // Q_PLUGIN_METADATA(IID "kstyleyo.kygui.ktextedit" FILE "ktextedit.json")
  10. Q_INTERFACES(QDesignerCustomWidgetInterface)
  11. public:
  12. QString toPlainText() {
  13. return QTextEdit::toPlainText();
  14. }
  15. void clear() {
  16. QTextEdit::clear();
  17. }
  18. signals:
  19. void textInputEnter();
  20. protected:
  21. virtual void keyPressEvent(QKeyEvent* e) {
  22. qDebug() << "Key press: " << e->key();
  23. if (e->key()==Qt::Key_Enter) {
  24. emit textInputEnter();
  25. }
  26. QTextEdit::keyPressEvent(e);
  27. }
  28. };
  29. #endif // KTEXTEDIT_HPP