title: How to Detect Alt+Enter pressed in QT
body: <p>I have QTextEdit and i want to detect "Alt+Enter" key is pressed (both keys together).
  I have installed the Event Filter to detect the key press events and when enter is press i can detect the key, but how do i detect that "Alt" key is also pressed?</p>
  
  <p>I tried to remember the "Alt" key press &amp; release (with static variable) but that does not help if user release the Alt key outside the application.</p>
  
  <p>see attached my code.</p>
  
  <pre><code>bool MTGridEditDelegate::eventFilter(QObject *obj,QEvent *event){
  static bool pressed = false;
  if(event-&gt;type() == QEvent::KeyPress)
  {
      if(static_cast&lt;QKeyEvent*&gt;(event)-&gt;key() == Qt::Key_Alt)
      {
          pressed = true;
          qDebug("Alt Pressed");
      }
  }
  if(event-&gt;type() == QEvent::KeyRelease)
  {
      if(static_cast&lt;QKeyEvent*&gt;(event)-&gt;key() == Qt::Key_Alt)
      {
          pressed = false;
          qDebug("Alt Released");
      }
  }
  
  if(event-&gt;type() == QEvent::KeyPress)
  {
      int key = static_cast&lt;QKeyEvent *&gt;(event)-&gt;key();
      qDebug("The Key is : %d",key);
      switch (static_cast&lt;QKeyEvent *&gt;(event)-&gt;key()) 
      {
          case Qt::Key_Backtab:
              break;
          case Qt::Key_Tab:
          case Qt::Key_Enter:
          case Qt::Key_Return:
          {
              QWidget *editor = ::qobject_cast&lt;QWidget*&gt;(obj);
              if(!pressed)
              {
                  emit commitData(editor);
                  emit closeEditor(editor, NoHint);
              }
              else
              {
                  MQTextEdit *editBox = qobject_cast&lt;MQTextEdit *&gt;(editor);
                  if (editBox)
                  {
                      QString text = editBox-&gt;toPlainText();
                      text = text + QChar('\n');
                      //text = text + QChar('\r');
                      editBox-&gt;setPlainText(text);
                  }
              }
              break;
          }
          case Qt::Key_Escape:
      //      CustControlFocusLost();
              break;
          default:
              return false;
  
      }
      return true;
  }
  else
  {
      return QObject::eventFilter(obj,event);
  }
  </code></pre>
  
  <p>}</p>