QT help button 和 setWhatsThis
来源:互联网 发布:mac 网络拓扑图软件 编辑:程序博客网 时间:2024/06/10 22:50
学习自《Foundations of Qt Development》
自定义窗口显示按钮: 帮助按钮和关闭按钮。
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint);
Qt::CustomizeWindowHint
用于将默认的按钮设置去除。或运算将关闭按钮和帮助按钮加入到对话框中。
设置两个checkBox的提示信息:
ui->checkBox->setWhatsThis(QObject::tr("this is a statement using <i>QObject::tr</i> for checkBox."));ui->checkBox_2->setWhatsThis(QObject::tr("<p style='white-space:pre'>this is a statement using <i>QObject::tr</i> " "for checkBox.</p>"));
之后,点击窗口的帮助按钮,打开what‘s this mode。光标移动到widget上就能显示出提示信息。
使用HTML标记 white-space:pre
可以取消自动换行。
关键code:
Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog){ setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint); ui->setupUi(this); ui->checkBox->setWhatsThis(QObject::tr("this is a statement using <i>QObject::tr</i> for checkBox.")); ui->checkBox_2->setWhatsThis(QObject::tr("<p style='white-space:pre'>this is a statement using <i>QObject::tr</i> " "for checkBox.</p>"));/*white-space:normal | pre | nowrap | pre-wrap | pre-line默认值:normal取值:normal: 默认处理方式。pre: 用等宽字体显示预先格式化的文本,不合并文字间的空白距离,当文字超出边界时不换行。可查阅pre对象nowrap: 强制在同一行内显示所有文本,直到文本结束或者遭遇br对象。pre-wrap: 用等宽字体显示预先格式化的文本,不合并文字间的空白距离,当文字碰到边界时发生换行。pre-line: 保持文本的换行,不保留文字间的空白距离,当文字碰到边界时发生换行。*/}
让人奇怪的是,同一份代码,在环境CentOS i686, Qt Creator 2.8.1, Based on Qt 5.1.1 (GCC 4.6.1, 32 bit) 下窗口显示不出帮助按钮(那个问号按钮)。而在win7, Qt Creator 4.2.1, Based on Qt 5.8.0 (MSVC 2015, 32 bit)下则正常运行。低版本的qt真有那么多的问题吗?
在CentOS i686, Qt Creator 2.8.1, Based on Qt 5.1.1 (GCC 4.6.1, 32 bit) 下的关键代码: setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint);
// Qt::WindowSystemMenuHint);
阅读全文
0 0
- QT help button 和 setWhatsThis
- qt button的位置和大小
- Qt - Button
- QT button 的三态
- qt里button相关
- Qt -- button的使用
- qt button的认知
- Qt Stylesheets Button Bar
- Qt笔记-qml-button
- qt的help页面字体太小
- Qt保持状态的Button
- Qt按钮控件(Button)
- 迷失button 和 input button
- Qt实现画板部件并和自定义button按钮结合实例
- help
- Help
- HELP
- help
- Session
- maven项目中hibernate创建步骤
- php编程初识
- BZOJ2821: 作诗(Poetize)(分块)
- .Java多分支;if……else…… 每吨货物每公里运费P与运输距离S有关,路途越远,每公里运价越低。两种解决方案
- QT help button 和 setWhatsThis
- 图解集合8:红黑树的移除节点操作
- First Position Unique Character
- JS 控制网页轮播图片的自动,按钮,导航原点转换
- LINUX常用命令
- Linux-网卡配置
- 布局以及本周学习的一些tips
- android反编译
- C#代码 登陆服务器