From 10ff385cb40d9a904db6f785179d209aae4105d0 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete <paul.tvete@qt.io> Date: Tue, 22 May 2018 16:07:53 +0200 Subject: [PATCH] Replace QAccel with QShortcut QShortcut is more powerful and easier to use. --- t14/gamebrd.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/t14/gamebrd.cpp b/t14/gamebrd.cpp index 743a91a..8ccc271 100644 --- a/t14/gamebrd.cpp +++ b/t14/gamebrd.cpp @@ -65,9 +65,10 @@ GameBoard::GameBoard(QWidget *parent) QLabel *hitsL = new QLabel( "HITS", this ); QLabel *shotsLeftL = new QLabel( "SHOTS LEFT", this ); - QAccel *accel = new QAccel( this ); - accel->connectItem( accel->insertItem( Qt::Key_Space), this, SLOT(fire()) ); - accel->connectItem( accel->insertItem( Qt::Key_Q), qApp, SLOT(quit()) ); + QShortcut *fireShortcut = new QShortcut(Qt::Key_Space, this); + connect(fireShortcut, SIGNAL(activated()), this, SLOT(fire())); + QShortcut *quitShortcut = new QShortcut(Qt::Key_Q, this); + connect(quitShortcut, SIGNAL(activated()), qApp, SLOT(quit())); quit->setGeometry( 10, 10, 75, 30 ); angle->setGeometry( 10, quit->y() + quit->height() + 10, 75, 130 ); -- GitLab