当前位置:网站首页>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是否存在同样的现象,欢迎有心人留言探讨!!
边栏推荐
猜你喜欢
【中山大学】考研初试复试资料分享
287. Find duplicates
Use cpolar to build a business website (1)
Method of accessing mobile phone storage location permission under non root condition
This article discusses the memory layout of objects in the JVM, as well as the principle and application of memory alignment and compression pointer
【LeetCode第 300 场周赛】
287. 寻找重复数
关于npm install 报错问题 error 1
Splay
同宇新材冲刺深交所:年营收9.47亿 张驰与苏世国为实控人
随机推荐
node の SQLite
Self-supervised Heterogeneous Graph Neural Network with Co-contrastive Learning 论文阅读
Cobra quick start - designed for command line programs
【LeetCode第 300 场周赛】
STM32+ENC28J60+UIP协议栈实现WEB服务器示例
QLabel 跑马灯文字显示
node の SQLite
Bonecp uses data sources
测试1234
Penetration test information collection - basic enterprise information
Automatic reservation of air tickets in C language
Medical image segmentation
RedisSystemException:WRONGTYPE Operation against a key holding the wrong kind of value
图之广度优先遍历
Cocos2d Lua smaller and smaller sample memory game
青龙面板最近的库
十、进程管理
STM32+MFRC522完成IC卡号读取、密码修改、数据读写
ORACLE进阶(四)表连接讲解
Some recruitment markets in Shanghai refuse to recruit patients with covid-19 positive