qkeysequence

How to call defined slots from keypress event in qt / How to connect keypressed event with QPushbutton on gui?

冷暖自知 提交于 2021-02-11 04:56:43
问题 I am beginner to qt. I was working on calculator gui application, I have already defined slots like numPressed() when any of the number pushbutton is pressed on the calculator that will be displayed on the lineEdit. void Calculator::numPressed(){ QPushButton *button = (QPushButton *)sender(); QString buttonValue = button->text(); Qstring display = ui->lineEdit->text(); Qdouble ProcessedValue = previousValue + buttonValue.toDouble(); . . . ui->lineEdit->setText(QString::number(ProcessedValue))

How to call defined slots from keypress event in qt / How to connect keypressed event with QPushbutton on gui?

情到浓时终转凉″ 提交于 2021-02-11 04:53:04
问题 I am beginner to qt. I was working on calculator gui application, I have already defined slots like numPressed() when any of the number pushbutton is pressed on the calculator that will be displayed on the lineEdit. void Calculator::numPressed(){ QPushButton *button = (QPushButton *)sender(); QString buttonValue = button->text(); Qstring display = ui->lineEdit->text(); Qdouble ProcessedValue = previousValue + buttonValue.toDouble(); . . . ui->lineEdit->setText(QString::number(ProcessedValue))

How to call defined slots from keypress event in qt / How to connect keypressed event with QPushbutton on gui?

折月煮酒 提交于 2021-02-11 04:52:57
问题 I am beginner to qt. I was working on calculator gui application, I have already defined slots like numPressed() when any of the number pushbutton is pressed on the calculator that will be displayed on the lineEdit. void Calculator::numPressed(){ QPushButton *button = (QPushButton *)sender(); QString buttonValue = button->text(); Qstring display = ui->lineEdit->text(); Qdouble ProcessedValue = previousValue + buttonValue.toDouble(); . . . ui->lineEdit->setText(QString::number(ProcessedValue))

Right justify QKeySequence in PyQt QAction Menu

泪湿孤枕 提交于 2020-01-05 12:16:51
问题 How I can right justify the QKeySequence in PyQt5? copy_absolute_path_action = ( create_action(self, _("Copy Absolute Path"), QKeySequence( get_shortcut('explorer', 'copy absolute path')), triggered=self.copy_absolute_path)) copy_relative_path_action = ( create_action(self, _("Copy Relative Path"), QKeySequence( get_shortcut('explorer', 'copy relative path')), triggered=self.copy_relative_path)) copy_file_clipboard_action = ( create_action(self, _("Copy File to Clipboard"), QKeySequence(get

PySide2 | Finding out which QKeySequence was pressed 2

自闭症网瘾萝莉.ら 提交于 2019-12-24 10:25:03
问题 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 only two buttons: self.btnDSR and self.btnOther. Taking from the answer of eyllanesc in the previous question, my code follows: class MainWindow(QtWidgets.QMainWindow, test_mainWindow.Ui_MainWindow): def __init__(self, parent=None): super

PySide2 | Finding out which QKeySequence was pressed

时光毁灭记忆、已成空白 提交于 2019-12-11 04:48:42
问题 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 QMainWindow: QtWidgets.QShortcut(QtGui.QKeySequence("1"),self).activated.connect(self.test_func) QtWidgets.QShortcut(QtGui.QKeySequence("2"),self).activated.connect(self.test_func) Such that they both execute this function. def test_func(self, signal): print(signal) Hoping that print("1") happens when the key "1

Qt: how to apply a shortcut( Key_Comma + Key_Return) to action

断了今生、忘了曾经 提交于 2019-12-02 14:06:50
问题 I tried to set a shortcut by the following code, but it doesn't work. If I change it to ALT + Comma or ALT + Return, it will be fine. but the request is Comma + Return. Does anyone know how to set this special shortcut on Qt? @shotcut = Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_Comma + Qt::Key_Return), self, SLOT('save_by_shortcut()')) @shotcut.setEnabled(true) Any help would be appreciated! 回答1: You can create it by using the multiple arguments constructor for QKeySequence. like this:

Qt: how to apply a shortcut( Key_Comma + Key_Return) to action

五迷三道 提交于 2019-12-02 05:21:07
I tried to set a shortcut by the following code, but it doesn't work. If I change it to ALT + Comma or ALT + Return, it will be fine. but the request is Comma + Return. Does anyone know how to set this special shortcut on Qt? @shotcut = Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_Comma + Qt::Key_Return), self, SLOT('save_by_shortcut()')) @shotcut.setEnabled(true) Any help would be appreciated! You can create it by using the multiple arguments constructor for QKeySequence . like this: auto ac = new QAction(this); ac->setShortcut(Qt::Key_Comma + Qt::Key_Return); 来源: https://stackoverflow.com