qspinputbox.cpp 767 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "qspinputbox.h"
  2. QspInputBox::QspInputBox(QWidget *parent) : QPlainTextEdit(parent)
  3. {
  4. m_selIndex = -1;
  5. }
  6. QspInputBox::~QspInputBox()
  7. {
  8. }
  9. void QspInputBox::SetText(const QString& text)
  10. {
  11. bool oldState = blockSignals(true);
  12. setPlainText(text);
  13. blockSignals(oldState);
  14. }
  15. QString QspInputBox::GetText()
  16. {
  17. return toPlainText();
  18. }
  19. void QspInputBox::keyPressEvent(QKeyEvent *event)
  20. {
  21. if ((event->key()==Qt::Key_Return || event->key() == Qt::Key_Enter) && (event->modifiers()==Qt::ControlModifier))
  22. {
  23. appendPlainText("\n");
  24. return;
  25. }
  26. else if (event->key()==Qt::Key_Return || event->key() == Qt::Key_Enter)
  27. {
  28. emit InputTextEnter();
  29. return;
  30. }
  31. QPlainTextEdit::keyPressEvent(event);
  32. }