android button 水平居中 android两个按钮居中_button按钮样式


QAbstractButton类是按钮小部件的抽象基类,提供按钮通用的功能。

按钮,常常被理解为触发一种动作请求或者命令,是与用户进行指令交互的操作。
Qt中Button系列根据用途被划分为不同的定义 Qt Designer提供6种 Button控件


QPushButton 按钮


android button 水平居中 android两个按钮居中_button按钮onclick触发不了_02


QAbstractButton类属性

  • text 显示文本
  • icon 设置图标
  • iconSize 图标大小
  • shortcut 设置快捷键
  • checkable 设置是否自动切换按钮
  • checked 设置默认选中状态
  • autoRepeat 设置是否会在用户按下时自动重复
  • autoExclusive 设置是否启用自动排他性(设置这个可以变成多选)
  • autoRepeatDelay 自动重复的初始延迟(以毫秒为单位)
  • autoRepeatInterval自动重复的时间间隔(以毫秒为单位)

QPushButton类属性

  • autoDefault 将按钮设置为对话框中的默认按钮
  • default 设置按钮的默认状态
  • flat 扁平化

QPushButton信号


android button 水平居中 android两个按钮居中_android button 水平居中_03


信号触发条件:

  • clicked() 当按钮被第一次按下然后释放时发出信号
  • clicked(bool) 当按钮被第一次按下然后释放时发出信号,并将当前状态传递给外界
  • pressed() 当鼠标光标在按钮内时按下鼠标左键发出信号
  • released() 当释放鼠标左键时发出信号
  • toggled(bool) 按钮的状态发生变化时发出信号,并将当前状态传递给外界

QToolButton工具按钮


android button 水平居中 android两个按钮居中_android button 水平居中_04


QAbstractButton类属性

  • 请参考QPushButton按钮

QToolButton类属性

  • popupMode 弹出模式

DelayedPopup 延迟弹出 MenuButtonPopup 菜单按钮弹出 InstantPopup 即时弹出

  • toolButtonStyle 工具按钮样式

ToolButtonIconOnly 仅显示图标 ToolButtonTextOnly 仅显示文本 ToolButtonTextBesideIcon 文本出现在图标的旁边 ToolButtonTextUnderIcon 文本出现在图标的下边 ToolButtonFollowStyle 按照样式显示

  • autoRaise 设置按钮浮动
  • arrowType 箭头样式

NoArrow 没有箭头 UpArrow 向上箭头 DownArrow 向下箭头 LeftArrow 向左箭头 RightArrow 向右箭头

QToolButton信号


android button 水平居中 android两个按钮居中_android button 水平居中_05


信号触发条件:

  • 前5个请参考QPushButton信号
  • triggered(QAction*) 当点击菜单中某个action时触发,并将action传递出来

QRadioButton 单选按钮


android button 水平居中 android两个按钮居中_android使两个按钮垂直居中显示_06


QAbstractButton类属性

  • 请参考QPushButton按钮

QRadioButton 信号


android button 水平居中 android两个按钮居中_button按钮的属性设置_07


信号触发条件:

  • 请参考QPushButton信号

QCheckBox 多选按钮


android button 水平居中 android两个按钮居中_button按钮的属性设置_08


QAbstractButton类属性

  • 请参考QPushButton按钮

QCheckBox类属性

  • tristate三种显示状态,其中两种返回True,一种返回False

信号触发条件

  • 前5个请参考QPushButton信号
  • stateChanged(int)返回当前状态是数值,如果勾选了tristate则返回(0,1,2)

QCommandLinkButton 命令链接按钮


android button 水平居中 android两个按钮居中_android button 水平居中_09


QAbstractButton类属性

  • 请参考QPushButton按钮

QPushButton类属性

  • autoDefault 将按钮设置为对话框中的默认按钮
  • default 设置按钮的默认状态

信号触发条件

  • 请参考QPushButton信号

QDialogButtonBox 按钮盒子


android button 水平居中 android两个按钮居中_button按钮样式_10


QDialogButtonBox类属性

  • orientation 排列方式

Horizontal 水平排列 Vertical 垂直排列

  • standardButtons 添加按钮
  • centerButtons 按钮居中

QDialogButtonBox 信号


android button 水平居中 android两个按钮居中_android button 水平居中_11


信号触发条件:

  • accepted() 点击yes,ok等,表示真按钮时发出信号
  • clicked(QAbstractButton*)点击所有按钮都可发出信号,并将所点击的按钮发送给外界
  • helpRequested() 点击help按钮时发出信号
  • rejected() 点击no,close等,表示假按钮时发出信号

每天一更,搞完收工