QPushButton上文字位置的设置(Qt4)
来源:互联网 发布:淘宝天文望远镜 编辑:程序博客网 时间:2024/06/16 08:08
最近在Qt中文论坛上看到这么一个提问,如题。
自己简单测试了一下,对于靠左、靠右的设定可以这么做:
左对齐
qApp->setStyleSheet("QPushButton{text-align : left;}");
右对齐
qApp->setStyleSheet("QPushButton{text-align : right;}");
qApp->setStyleSheet("QPushButton{text-align : left;}");
右对齐
qApp->setStyleSheet("QPushButton{text-align : right;}");
或者是:
//左对齐
pushButton.setStyleSheet("QPushButton{text-align : left;}");
//右对齐
pushButton.setStyleSheet("QPushButton{text-align : right;}");
pushButton.setStyleSheet("QPushButton{text-align : left;}");
//右对齐
pushButton.setStyleSheet("QPushButton{text-align : right;}");
第一种方法的缺点是,使用qApp设定按钮对齐的话,界面上的所有按钮都将按设定后的方式显示。
第二种方法相对好一些。使用CSS样式表来单独设定想要设定的按钮。
如果要实现按钮文字的左上、左下、右上、右下对齐的话,需要重写了QPushButton的PaintEvent事件。
- QPushButton上文字位置的设置(Qt4)
- QPushButton上文字位置的设置(Qt4)
- 1QPushButton的使用,QLineEdit的使用,设置组件位置,布局(QHBoxLayout,QGridLayout)
- iOS Button 上文字图片位置的设置
- 设置button的Alignment;button上的文字位置(居左居右)
- 设置QPushButton的背景图片
- 设置QPushButton的背景图片
- 设置QPushButton的背景图片
- Qt4 设置位置 setGeometry
- Qt QPushButton QLabel 文字显示不全是设置成... 缩写的方式
- QPushButton设置背景图片的方法
- QPushButton的一些stylesheet设置
- UIButton的UIEdgeInsets功能:设置button上的文字和图片的位置
- iOS - UIButton(UIEdgeInsets)/设置button上的文字和图片 在定义位置
- 28.iOS - UIButton(UIEdgeInsets)/设置button上的文字和图片 在定义位置
- iOS - UIButton(UIEdgeInsets)/设置button上的文字和图片 在定义位置
- 设置QPushButton的平面与突出(遍历控件)
- Swift - 给图片添加文字水印(图片上写文字,并可设置位置和样式)
- Linux 下线程同步
- MYSQL优化配置
- Android开发指南-用户界面-用户通知
- 在项目中用Spring的Acegi安全框架的步骤
- DELPHI Showmodal 模式窗体
- QPushButton上文字位置的设置(Qt4)
- tomcat之session和cookie
- 获取SQL Server的当前连接数
- su - make the shell a login shell
- linux java/jsp 获取系统当前时间问题
- 消费型网站前期工作分配探讨
- shell 精典总结
- Linux下的软链接和硬链接的不同【转】
- CRM告诉你如何更快速有效的跟踪客户