CTRL+X/C/V/A for custom widgets
-
Hi!
I'd like to assign cut, copy, paste and select all shortcuts to a QGraphicsView widget.
If I do this using menus (which is how I'd like to) and assign each action with its corresponding shortcut, I override shortcuts for all other widget ( QTextEdit, QLineEdit ...).How can I solve this?
If possible, I'd like to have this actions listed in QMenu with shortcuts.
I also looked over an alternative, overriding QGraphicsView::keyPressEvent, and may question is, is Qt::key_Copy for ctrl+c?
Thanks in advance.
Regards,
JakeEDIT:
It works with default widgets. It does not work with inherited QTextEdit and overridden keyPressEvent();Code:
@void ConsoleOutput::keyPressEvent(QKeyEvent *e)
{
switch(e->key())
{
case Qt::Key_Enter:
case Qt::Key_Return:
emit returnPressed();
output("<br />");
break;
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Up:
case Qt::Key_Down:
break;
default:
cursorToEnd();
}if(myFirstInput)
{
myFirstInput = false;myOrg = this->toPlainText();
myLen = this->toPlainText().length();
}else if(e->key() == Qt::Key_Backspace)
{
if(toPlainText().size() < myLen)
return;else if(toPlainText()[(toPlainText().size()-1)] == '\n')
return;
}QTextEdit::keyPressEvent(e);
}@