本文持续更新,在以后的工作中如果遇到了新的问题时,会更新本文
1. 简介
QDialogButtongBox类是一个包含很多按钮的控件,在对话框中有多个按钮需要分组排列的按钮时,可以使用QDialogButtongBox类。
对话框或者消息框中的按钮布局,不同平台风格不同。开发人员可以向QDialogButtonBox添加按钮,在添加后QDialogButtonBox会为用户自动使用合适的布局。
Header: | #include |
---|---|
qmake: | QT += widgets |
Since: | Qt 4.2 |
Inherits: | QWidget. |
2. 对话框中的标准按钮
对于对话框中的标准按钮(如,OK,Cancel,Save)可以在QDialogButtonBox创建时,使用flag标志的或运算指定。
3. 对话框中按钮的布局
另外,QDialogButtongBox中的按钮,可以水平排列也可以竖直排列。在创建 QDialogButtongBox时,通过指定参数Qt::Orientation orientation 来指定按钮的布局方式。
buttonBox = new QDialogButtonBox(Qt::Horizontal);
QPushButton *mkdirButton = buttonBox->addButton(
tr("&Create Directory..."), QDialogButtonBox::ActionRole);
QPushButton *removeButton = buttonBox->addButton