Unsolved How to bind Ctrl C to delete Key
-
Hi
I have a QTableWidget and I have to bind Ctrl + key and Delete to TQableWIdgeton Ctrl +C - I should be able to clear the contents of selected row
on Delete key I should be able to delete the selected row
Can someone help me in writing a prototype code for the same
-
If that widget is MainWindow, you can create QShortcut http://doc.qt.io/qt-5/qshortcut.html
If you want only for that widget override your keyPressEvent to check for Ctrl+C.
https://forum.qt.io/topic/20982/solved-how-to-handle-all-the-keys-in-key-press-release-event/2 -
Hi,
On a side note, it's not a good idea to use
CTRL+C
to clear something. People are used to use that shortcut to copy something. While you are free to use whatever combo you want, you are likely going to take your users by surprise as your application would behave counter intuitively. -
yeah I think I mean CTrl + X
-
Other nitpick: CTRL+X is for cut. Therefore it should remove stuff but users also expect to be able to past what they have cut somewhere else.
-
Agree with @SGaist
Why not CTRL+del or CTRL+backspace
This is what I'm using:// CTRL+BS #ifdef Q_OS_MAC shortcut= new QShortcut(QKeySequence(Qt::META+Qt::Key_Backspace),this); #else shortcut= new QShortcut(QKeySequence(Qt::CTRL+Qt::Key_Backspace),this); #endif connect(shortcut,SIGNAL(activated()),this,SLOT(applicationShortcut()));
-
@mpergand said in How to bind Ctrl C to delete Key:
shortcut= new QShortcut(QKeySequence(Qt::META+Qt::Key_Backspace),this);
what is key good for good for deleting the row of QtableWidget
-
Could be shift or ctrl + delete or even all three to ensure people don't do that by accident. The combination @mpergand suggested with backspace is not a bad idea either.