The QKeyEvent class, part of the Qt framework, describes a key event.
Questions tagged [qkeyevent]
73 questions
1
vote
1 answer
Can't access some supposedly public properties on the QKeyEvent object
There is a list of public properties here: http://doc.qt.io/qt-5/qkeyevent.html
I try to access them:
Keys.onPressed: {
console.log("matches: ", event.matches("="));
console.log("text: ", event.text());
…

user1283776
- 19,640
- 49
- 136
- 276
1
vote
1 answer
QKeyPress - Simulating key press in Qt
How can I simulate user interaction (key press event) in Qt?
I tried the same approach, but not able to get written on the lineEdit widget
ui->lineEdit->setFocus();
QKeyEvent *key_press = new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_X,…

Sayan Bera
- 135
- 2
- 16
1
vote
0 answers
QKeySequence 'CTRL + PLUS' shortcut doesn't work for german keyboard layout
I'm new to Qt and advanced Programming. In my project, I have a QKeySequence shortcut CTRL + PLUS & CTRL + MINUS keys. They work fine in numerical PLUS & MINUS Keys but, they don't trigger required action if used in OEM PLUS & MINUS Keys for German…

porchezhiyan
- 31
- 5
1
vote
1 answer
Qt keyPressEvent handler only reacts when ctrl, alt or shift key is pressed
I tried to get any key using keyPressEvent() function, but I found out in debug mode that this function is called only when the key "shift/alt/ctrl" is pressed. I tried to press the key in textEdit box.
tipmanager.h :
namespace Ui {
class…

Sean
- 301
- 1
- 2
- 10
1
vote
2 answers
How to change space bar behaviour in PyQt5, Python3
I made a ui for work using PyQt5 and Python3. Additionally to clicking the buttons, I want to execute specific actions by pressing specific keys on my keyboard e.g. the space bar. I used the following to do so:
def keyPressEvent(self, event):
…

Pandora
- 29
- 1
- 4
1
vote
2 answers
Call function by Enter key
How can I make (on_click) works when QPushButton ("click") is pressed by Enter keyboard key? it only interacts with mouse_click
import sys
from PyQt5.QtWidgets import *
class Example(QMainWindow):
def __init__(self):
…

gin
- 873
- 2
- 12
- 23
1
vote
1 answer
Handle arrow key events by setting the focus policy
I want to handle key events of the arrow keys in my application. I have already read that for doing so the focus must be disabled. I follow this method: PyQt not recognizing arrow keys. Indeed, when calling…

Michael Westwort
- 914
- 12
- 24
1
vote
1 answer
Get key position of QKeyEvent (multiplatform)
In order to make position-based keyboard shortcuts, that work for all keyboard layouts, I need to identify a physical keyboard key, without the keyboard layout on top of it. Ideally, I would like to retrieve the scancode of the QKeyEvent, because…

Tomasito665
- 1,188
- 1
- 12
- 24
1
vote
1 answer
How to send QKeyEvent to specific qml item?
I'm trying to send a custom QKeyEvent (like Keypress key B) to an item (like TextField) in my QML file. This is what I've wrote which it doesn't work. It seems that the item (TextField) doesn't get my event (I'm assuming this because no B characters…

Shnd
- 1,846
- 19
- 35
1
vote
1 answer
Unexpected behaviour with QMouseMoveEvent and QKeyEvent modifiers
I am encountering unexpected behaviour in my code.
I have a QGraphicsView containing a QGraphicsScene. Now I want to detect the mouse wheel for zooming the view and mouse moving for moving items in the scene, the latter only while controll is…

honiahaka10
- 772
- 4
- 9
- 29
1
vote
1 answer
Making moving 2D object in Qt OpenGL
I write a deathmatch multiplayer "tanks" game where players can join to server and run a Tank, shoot etc. At the moment I want to make the mechanism of movement around the map (2D). I've tried some methods but they are not satisfying.
Right now I'm…

Tomasz Kasperek
- 1,147
- 3
- 13
- 35
1
vote
1 answer
how to accept/ignore QKeyEvent
http://qt-project.org/doc/qt-5/qwidget.html#keyPressEvent
Note that QKeyEvent starts with isAccepted() == true, so you do not
need to call QKeyEvent::accept() - just do not call the base class
implementation if you act upon the…

Trass3r
- 5,858
- 2
- 30
- 45
1
vote
2 answers
Keyboard letters of a to z are not working in keyPressEvent in Qt
I am using KeyPressEvent in my applicatiion. But letters from a to z are not working.
void mywindow::keyPressEvent(QKeyEvent *event)
{
switch(event->key())
{
case Qt::Key_Left:
break;
}
}
This is working properly
But…

Suresh
- 745
- 4
- 11
- 25
1
vote
2 answers
Capturing text change events in a QComboBox
I am developing a Qt application on Red Hat Linux. I want to capture Carriage Return key press events in a QComboBox.
I have connected a slot to the signal editTextChanged() which is emitted for every key press but not for the Enter Key.
Why so? Is…

Muhammad Ummar
- 3,541
- 6
- 40
- 71
1
vote
1 answer
get shift+numerical keys in qt using qkeyevent
I am using QKeyEvent to get the Shift+numeric key, but it return me the ascii for "!" instead of "1" so my problem is, is there any method or techniques to get the actual numeric value's ascii instead of ascii of "!" (special character). I also…

Ali Hassan
- 607
- 1
- 11
- 24