当前位置:网站首页>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是否存在同样的现象,欢迎有心人留言探讨!!
边栏推荐
猜你喜欢
随机推荐
44所高校入选!分布式智能计算项目名单公示
A method of sequentially loading Unity Resources
十、进程管理
bonecp使用数据源
[Sun Yat sen University] information sharing of postgraduate entrance examination and re examination
Penetration test information collection - CDN bypass
How does crmeb mall system help marketing?
深度循环网络长期血压预测【翻译】
图片缩放中心
基于蝴蝶种类识别
Deep circulation network long-term blood pressure prediction [translation]
美庐生物IPO被终止:年营收3.85亿 陈林为实控人
Some understandings of tree LSTM and DGL code implementation
There is a sound prompt when inserting a USB flash disk under win10 system, but the drive letter is not displayed
Noninvasive and cuff free blood pressure measurement for telemedicine [translation]
SQL injection - access injection, access offset injection
文档编辑之markdown语法(typora)
Cocos2d Lua smaller and smaller sample memory game
涂鸦智能在香港双重主板上市:市值112亿港元 年营收3亿美元
Grafana 9.0 is officially released! It's the strongest!
![Optical blood pressure estimation based on PPG and FFT neural network [translation]](/img/88/2345dac73248a5f0f9fa3142ca0397.png)








