当前位置:网站首页>QPushButton绑定快捷键的注意事项
QPushButton绑定快捷键的注意事项
2022-07-06 11:01:00 【HL_风神】
在一个日常开发当中,需要为按钮添加一个快捷键操作,指定键盘上的一个按键按下相当于用鼠标点击了这个按钮,这就是快捷键的作用
有个现象是当添加快捷键的顺序是这样的话,快捷键无效
先进行快捷键的绑定,再进行按钮文本的设置,无效
QKeySequence keyCut(Qt::Key_Return);
btnStart->setShortcut(keyCut);
btnStart->setText("开始");
先进行文本的设置,再进行快捷键的绑定,有效
btnStart->setText("开始");
QKeySequence keyCut(Qt::Key_Return);
btnStart->setShortcut(keyCut);
然后我再试了一下将设置文本的代码注释掉,再绑定快捷键,运行程序,按下回车,我靠,程序崩溃了
//btnStart->setText("开始");
QKeySequence keyCut(Qt::Key_Return);
btnStart->setShortcut(keyCut);
以上就是我在一个日常开发中发现的一个小细节,不清楚是不是我版本Qt5.7.1太低的原因,目前没有去试试高版本的Qt是否存在同样的现象,欢迎有心人留言探讨!!
边栏推荐
- 徐翔妻子应莹回应“股评”:自己写的!
- RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
- Xu Xiang's wife Ying Ying responded to the "stock review": she wrote it!
- Penetration test information collection - App information
- From 2022 to 2024, the list of cifar azrieli global scholars was announced, and 18 young scholars joined 6 research projects
- 287. 寻找重复数
- Implementation of AVL tree
- 随着MapReduce job实现去加重,多种输出文件夹
- Alibaba cloud international ECS cannot log in to the pagoda panel console
- Self-supervised Heterogeneous Graph Neural Network with Co-contrastive Learning 论文阅读
猜你喜欢
[matlab] Simulink the input and output variables of the same module cannot have the same name
Execution process of MySQL query request - underlying principle
[Matlab] Simulink 同一模块的输入输出的变量不能同名
If you have any problems, you can contact me. A rookie ~
Tree-LSTM的一些理解以及DGL代码实现
【LeetCode第 300 场周赛】
星诺奇科技IPO被终止:曾拟募资3.5亿元 年营收3.67亿
Grafana 9.0 is officially released! It's the strongest!
C#/VB. Net to add text / image watermarks to PDF documents
Docker installation redis
随机推荐
C#/VB.NET 给PDF文档添加文本/图像水印
Echart simple component packaging
Picture zoom Center
同宇新材冲刺深交所:年营收9.47亿 张驰与苏世国为实控人
Test 1234
Cocos2d Lua 越来越小样本 内存游戏
Jushan database was among the first batch of financial information innovation solutions!
There is a sound prompt when inserting a USB flash disk under win10 system, but the drive letter is not displayed
atcoder它A Mountaineer
徐翔妻子应莹回应“股评”:自己写的!
Docker安装Redis
星诺奇科技IPO被终止:曾拟募资3.5亿元 年营收3.67亿
Epoll () whether it involves wait queue analysis
Online notes
Cocos2d Lua smaller and smaller sample memory game
Blue Bridge Cup real question: one question with clear code, master three codes
Splay
2022-2024年CIFAR Azrieli全球学者名单公布,18位青年学者加入6个研究项目
From 2022 to 2024, the list of cifar azrieli global scholars was announced, and 18 young scholars joined 6 research projects
Hongke shares | plate by plate ar application in Beijing Winter Olympics