当前位置:网站首页>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是否存在同样的现象,欢迎有心人留言探讨!!
边栏推荐
- 同宇新材冲刺深交所:年营收9.47亿 张驰与苏世国为实控人
- [sword finger offer] 60 Points of N dice
- Alibaba cloud international ECS cannot log in to the pagoda panel console
- 线代笔记....
- 2022-2024年CIFAR Azrieli全球学者名单公布,18位青年学者加入6个研究项目
- Method of accessing mobile phone storage location permission under non root condition
- Optical blood pressure estimation based on PPG and FFT neural network [translation]
- 用于远程医疗的无创、无袖带血压测量【翻译】
- STM32+ENC28J60+UIP协议栈实现WEB服务器示例
- Breadth first traversal of graph
猜你喜欢

Method of accessing mobile phone storage location permission under non root condition

巨杉数据库首批入选金融信创解决方案!
![Noninvasive and cuff free blood pressure measurement for telemedicine [translation]](/img/56/8deaec18cd9f2cf49ff234b09b1283.png)
Noninvasive and cuff free blood pressure measurement for telemedicine [translation]

Xu Xiang's wife Ying Ying responded to the "stock review": she wrote it!

【中山大学】考研初试复试资料分享

Penetration test information collection - CDN bypass

关于npm install 报错问题 error 1

2022-2024年CIFAR Azrieli全球学者名单公布,18位青年学者加入6个研究项目
![Estimate blood pressure according to PPG using spectral spectrum time depth neural network [turn]](/img/f2/194ae452609d3e474b7b580d61bf4f.png)
Estimate blood pressure according to PPG using spectral spectrum time depth neural network [turn]

同宇新材冲刺深交所:年营收9.47亿 张驰与苏世国为实控人
随机推荐
Tree-LSTM的一些理解以及DGL代码实现
Introduction and case analysis of Prophet model
node の SQLite
Stm32+mfrc522 completes IC card number reading, password modification, data reading and writing
用友OA漏洞学习——NCFindWeb 目录遍历漏洞
涂鸦智能在香港双重主板上市:市值112亿港元 年营收3亿美元
C#/VB. Net to add text / image watermarks to PDF documents
Xu Xiang's wife Ying Ying responded to the "stock review": she wrote it!
Easy to use PDF to SVG program
With the implementation of MapReduce job de emphasis, a variety of output folders
Blue Bridge Cup real question: one question with clear code, master three codes
Jdbc driver, c3p0, druid and jdbctemplate dependent jar packages
首先看K一个难看的数字
Handwritten online chat system (principle part 1)
Visual Studio Code启动时提示“Code安装似乎损坏。请重新安装。”、标题栏显示“不受支持”信息的解决办法
On AAE
朗坤智慧冲刺科创板:年营收4亿 拟募资7亿
Describe the process of key exchange
[Sun Yat sen University] information sharing of postgraduate entrance examination and re examination
RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value