Questions tagged [qshortcut]
14 questions
8
votes
1 answer
PyQt trigger a button with ctrl+Enter
I'm trying to make a trigger for the Ok button in my application
The current code I tried was this:
self.okPushButton.setShortcut("ctrl+Enter")
However, it doesn't work, which kind of makes sense. I tried looking up some key sequences here, but,…

tisaconundrum
- 2,156
- 2
- 22
- 37
4
votes
2 answers
How do I make a shortcut using arrow key with PySide2?
I want to add a keyboard shortcut to a button with Qt5 + Python (Pyside2). Code for making a shortcut with a regular key:
import sys
import random
from PySide2 import QtCore, QtWidgets, QtGui
class MyWidget(QtWidgets.QWidget):
def…

mebaka
- 61
- 1
- 4
1
vote
0 answers
Is there a way to trigger a QShortcut on a button release?
I currently have this, which functions as expected, running on keyboard button press.
# QWidget == widget shortcut is assigned to
shortcut = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_M),…

Adam Sirrelle
- 357
- 8
- 18
1
vote
1 answer
PyQt5 Define the slot in a separate module for QShortcut
Main interacts with a GUI defined by a separate module. Two alternative approaches are used in Main to define the slot for a QShortcut. The lambda method works (but seems cumbersome). The direct method works, only if the lambda method is executed…

Steve Cannon
- 17
- 4
1
vote
1 answer
QShortcut & QKeySequence with Shift+Return in a QPlainTextEdit element
I have an element, editorBox which is of the PyQt5 element type QPlainTextEdit. My target goal is to call a function when the hotkey Shift + Return is pressed, and my goal with this function is that it will also insert text into the editorBox…

Xiddoc
- 3,369
- 3
- 11
- 37
1
vote
1 answer
QVideoWidget in full-screen mode no longer responds to hotkeys or mouse wheel
Using QVideoWidget in PySide2 (although the python part may not be significant). I've set up my hotkeys using QShortcut, and it all works great. When I press 'F' to enter full-screen mode that works too, but then I can't leave. None of my hotkeys…

fuzzboil
- 61
- 1
- 5
1
vote
1 answer
PySide2 | Finding out which QKeySequence was pressed 2
I had a previous question about QKeySequence here. It worked but when I applied it to my code there seemed to be an error when the QKeySequence comes after line when the button click event goes before the QKeySequence line.
Note: The GUI consists of…

Teacher Mik
- 147
- 3
- 9
1
vote
1 answer
Finding out which QKeySequence was pressed
I'm using PySide2 and I want to have multiple shortcuts that carry out the same function but also would depend on which key was pressed.
I tried to link the functions as such inside a…

Teacher Mik
- 147
- 3
- 9
0
votes
1 answer
'Shift+Return' QShortcut in PyQt QPlainTextEdit
I'm attempting to write a small command line console in PyQt, similar to the Jupyter Qtconsole . As a simple first step I'd like to be able to execute commands when the key combination 'Shift+Return' is pressed. The code example below suggests…

cjordan1
- 277
- 1
- 4
- 11
0
votes
1 answer
QShortcut - how to correcly declare in widget?
i am trying to use QShortcut, and declare in in widget constructor like:
QShortcut *keyCtrlL;
keyCtrlL = new QShortcut(this);
keyCtrlL->setKey(Qt::CTRL + Qt::Key_L);
connect(keyCtrlL, &QShortcut::activated, this, &MyPage::loadB);
I…

user453575457
- 464
- 6
- 21
0
votes
0 answers
Is it possible to set a modifier as a QShortcut?
shortcut = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Shift), MayaMainWindow)
shortcut.setContext(QtCore.Qt.ApplicationShortcut)
I have a system in place for overloading Maya shortcuts, as and when needed. I want to do this with the shift…

Adam Sirrelle
- 357
- 8
- 18
0
votes
2 answers
Can't bind signal to slot in my Qt application
I'm new to Qt and I have a very simple demo app. It just include a QLineEdit widget and I want to invoke a function test() when I press ctrl+p in the QLineEdit.
Below are the related files.
mainwindow.cpp
#include "mainwindow.h"
#include…

Just a learner
- 26,690
- 50
- 155
- 234
0
votes
1 answer
How can I change animation of button when using QShortcut?
Before, I was used to using button.clicked.connect(function) to trigger a button and setting qss by setStyleSheet() (Eg:
QPushButton:pressed{background:#EAEAEA;}). And the button will change background color when pressing button by clicking mouse…

leminhnguyen
- 1,518
- 2
- 13
- 19
-1
votes
1 answer
PyQt5 Keyboard shortcut for QTableWidget stops working when table is cleared
I have a QTableWidget that I want to attach a shortcut to to advance to the next cell when the Enter/Return key is pressed using the code I found below. I reuse the table a couple of times so I call the clear() method in between populating the table…

BdT141
- 13
- 3