if this condition is false

Qt Code:
  1. if (event->type() == QEvent::KeyPress)
To copy to clipboard, switch view to plain text mode 

then your function does not return anything. may be this is the issue.