Questions tagged [qkeyevent]

The QKeyEvent class, part of the Qt framework, describes a key event.

Documentation can be found here (Qt4) and here (Qt5).

73 questions
14
votes
2 answers

Get the "name" of a key from QKeyEvent in Qt

Is there an easy way of getting the name of a key (so something like "uparrow" from a key event instead of just getting the key code "16777235")? Do I have to make a list of key names myself?
Ben
  • 470
  • 1
  • 6
  • 18
13
votes
3 answers

How can I disable Alt + F4 window closing using Qt?

I've disabled X button in Qt from my dialog using this line: myDialog->setWindowFlags(Qt::Dialog | Qt::Desktop) but I couldn't detect Alt + F4 using this code: void myClass::keyPressEvent(QKeyEvent *e) { if ((e->key()==Qt::Key_F4) &&…
Mohammad Sheykholeslam
  • 1,379
  • 5
  • 18
  • 35
10
votes
3 answers

Qt Key Pressevent Enter

void LoginModle::keyPressEvent(QKeyEvent *event) { qDebug() << event->key() << "\t" << Qt::Key_Enter << "\t" << QKeyEvent::Enter; if( event->key() == Qt::Key_Enter) OKButtonClicked(); else …
Anudorannador
  • 189
  • 1
  • 1
  • 11
7
votes
2 answers

How to convert a Windows native virtual key code to Qt::Key?

I am working on a program which communicates with a windows native program, so it needs the actucal native virtual key code. How to convert from a Windows native virtual key code to Qt::Key?
jay
  • 1,032
  • 2
  • 13
  • 20
7
votes
4 answers

Qt keyPressEvent not registering when W/A/S/D keys are pressed

I have an app (not related to any game where the W/A/S/D keys may have special meanings for navigation) where there is a QFrame. I overrode the keyPressEvent() to get the text being typed through keyboard while focus in on that QFrame. This is my…
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
5
votes
1 answer

Always have focus policy on hidden widget? (Qt C++)

I am learning to process keypress and keyrelease events in Qt (C++). I have a class Keyboard with which I want to process all of these events. It inherits QObject. It doesn't need to process any mouse events. I am trying to figure out how I can…
John
  • 640
  • 2
  • 8
  • 18
5
votes
3 answers

Qt sending keyPressEvent

I want to append chars to QLineEdit by sending KeyEvent. I'm using code like this: ui.myEdit->setFocus(); for(size_t i = 0; i < 10; ++i) { QKeyEvent keyPressed(QKeyEvent::KeyPress, 'a', Qt::NoModifier); QWidget::keyPressEvent(&keyPressed); //…
user3369485
  • 117
  • 1
  • 1
  • 7
4
votes
1 answer

Overriding keyPressEvent in QTextEdit subclass

I have the following example in Qt in which I try to override the keyPressEvent of a subclass of QTextEdit, but gives me a "multiple definition of txt::keyPressEvent(QKeyEvent*)" and I can't figure out why: //txt.h #ifndef TXT_H #define…
Nini Michaels
  • 341
  • 7
  • 17
4
votes
1 answer

How to check if [Shift + Tab] is being pressed in QT

How would one check if the SHIFT key is held and the TAB key is pressed with a QKeyEvent? I've tried using: (event->key() == Qt::Key_Tab && event->modifiers() == Qt::ShiftModifier) However, the event->key() is not equal to Qt::Key_Tab whenever the…
Griffort
  • 1,174
  • 1
  • 10
  • 26
4
votes
2 answers

How to synthesize key press events?

I am able to get key value's from HAL through a call back function in Qt. Created event for that key by QKeyEvent *event = new QKeyEvent (QEvent::KeyPress, inputKey.keyValue, …
Lalatendu
  • 79
  • 1
  • 6
3
votes
1 answer

how to detect a key release in pyqt

I want to create a PyQt5 window (Windows OS) which recognizes a button click with holding CTRL button. I successfully created a handler which recognizes CTRL key press but it couldn't find the pressing and releasing of a button which i need to call…
Siva Manasan
  • 123
  • 4
  • 14
3
votes
1 answer

How to call qt keyPressEvent(QKeyEvent *event) from qml Keys.onPressed

I have a qml Window with an Item which has Keys.onPressed { } And I have a c++ class which has protected: void keyPressEvent(QKeyEvent *event); What needs to go inside the Keys.onPressed? I have tried …
mango
  • 35
  • 6
3
votes
0 answers

Qt - How to convert Qt::Key into nativeVirtualKey

How can I convert a Qt::Key (eg. Qt::Key_At) into nativeVirtualKey code outside of a keyPressEvent() or a keyReleaseEvent()?
Junior
  • 507
  • 5
  • 19
3
votes
4 answers

Limit QKeySequence/QKeySequenceEdit to only one shortcut

Is it possible to limit QKeySequence to show only one shortcut in QKeySequenceEdit? Currently now it supports up to 4 shortcuts. My application supports key sequences of only one shortcut, e.g. Ctrl+A or Ctrl+C and not e.g. Ctrl+A, D or Ctrl+C, X,…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
2
votes
1 answer

PyQt QTableView - Capture KeyDown / KeyPress Event

I would like to capture a Key Down Event on a QTableView. I would also like to determine, if it was a keydown on DEL button, my QTableView is created like this (from QtCreator): self.tblview_data_sources =…
Project_Prkt
  • 91
  • 1
  • 12
1
2 3 4 5