Qt android handling Backbutton pressed
-
wrote on 8 Aug 2017, 09:07 last edited by
How to minimize application on backkey pressed in android
-
wrote on 8 Aug 2017, 09:42 last edited by
void Widget::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Backspace:
this->showMinimized();
break;
default:
QWidget::keyPressEvent(event);
}
} -
void Widget::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Backspace:
this->showMinimized();
break;
default:
QWidget::keyPressEvent(event);
}
}wrote on 8 Aug 2017, 10:21 last edited by@Vinod-Kuntoji
thanks for reply .. actually i am not using widgets .. i need in qml .. -
wrote on 8 Aug 2017, 11:05 last edited by Vinod Kuntoji 8 Aug 2017, 11:28
Item {
focus: true
Keys.onPressed: {
console.log(event.key)
if (event.key === Qt.Key_Back) {
mainWindow.showMinimized();
event.accepted = true;
}
}
}
It wont work, but it will print key value.
something like 16777219.
I used this value to compare with event key.
It worked
if (event.key === 16777219) {
mainWindow.showMinimized();
}
4/4