Hello!
I've got simple application in which I need to use 4 keyboard keys (arrows) to move point on my widget. I've got something like this in main window:
void MainWindow
::keyPressEvent( QKeyEvent *k
) {
switch ( k->key() )
{
case Qt::Key_Up:
qDebug() << "UP";
break;
case Qt::Key_Down:
qDebug() << "DOWN";
break;
case Qt::Key_Left:
qDebug() << "LEFT";
break;
case Qt::Key_Right:
qDebug() << "RIGHT";
break;
default:
qDebug() << k->key() << endl;
break;
}
}
void MainWindow::keyPressEvent( QKeyEvent *k )
{
switch ( k->key() )
{
case Qt::Key_Up:
qDebug() << "UP";
break;
case Qt::Key_Down:
qDebug() << "DOWN";
break;
case Qt::Key_Left:
qDebug() << "LEFT";
break;
case Qt::Key_Right:
qDebug() << "RIGHT";
break;
default:
qDebug() << k->key() << endl;
break;
}
}
To copy to clipboard, switch view to plain text mode
Inside I wanted to put function which changes coordinates of point inside widget. But only up/down keys works (prompt goes to first text edit window). How can I make it other way? I've read about qshortcuts but I don't know if I can use it (it can by shortcuts to real buttons on my application - then I'll make them).
thanks in advance
best regards
Tomasz
Bookmarks