We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我发现凡是用到了快捷键的例子没一个好用的 py version: 3.11.9 OS:win11
The text was updated successfully, but these errors were encountered:
你好,这个应该是pyqt的问题。 以Chapter05/qt_QSqlQueryModel.py为例。 代码
Chapter05/qt_QSqlQueryModel.py
menu.addAction(QIcon("images/right.png"), '后一页', QKeySequence(Qt.Modifier.CTRL | Qt.Key.Key_N), self.onNextButtonClick)
和
next = QAction(QIcon("images/right.png"),'后一页',self) next.setShortcut(QKeySequence(Qt.Modifier.CTRL|Qt.Key.Key_N)) next.triggered.connect(self.onNextButtonClick) menu.addAction(next)
是等价的,而后者在这个案例中快捷键也无效,但是从菜单中点击的时候,确实触发了onNextButtonClick方法。
参考案例Chapter04/qt_QShortcut.py,后者的快捷键绑定是没问题的。 也就是说,我们正确设置了快捷键绑定,但是没有成功触发,这应该是pyqt的bug.
Chapter04/qt_QShortcut.py
解决方法可以参考Chapter04/qt_QShortcut.py案例,使用自定义shortcut, 再次绑定一次快捷键:
menu.addAction(QIcon("images/right.png"), '后一页', QKeySequence(Qt.Modifier.CTRL | Qt.Key.Key_N), self.onNextButtonClick) short_next = QShortcut(QKeySequence("Ctrl+N"),self) short_next.activated.connect(self.onNextButtonClick)
在很早的pyqt6.2版本,shortcut参数要放在slot参数之后,现在要放在slot参数之前,不知道是不是这个变化导致的快捷键失效。
Sorry, something went wrong.
No branches or pull requests
我发现凡是用到了快捷键的例子没一个好用的
py version: 3.11.9
OS:win11
The text was updated successfully, but these errors were encountered: