我在网上查了很久都没有。有谁知道如何访问按钮框中的按钮(使用“右按钮对话框”模板创建)?
最佳答案
在 Designer 中,选择 OK
或 Cancel
按钮。然后打开属性编辑器并向下滚动到 QDialogButtonBox
部分。然后您可以展开 standardButtons
项以查看可用的各种按钮。其他属性,例如 centerButtons
属性,也可用。
但是,设计器让您对按钮框的控制非常少。
在代码中,您可以做很多其他事情,例如更改出现在“标准按钮”上的文本。来自documentation :
findButton = new QPushButton(tr("&Find"));
findButton->setDefault(true);
moreButton = new QPushButton(tr("&More"));
moreButton->setCheckable(true);
moreButton->setAutoDefault(false);
buttonBox = new QDialogButtonBox(Qt::Vertical);
buttonBox->addButton(findButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole);
只要在设计器中给按钮框起个名字,就可以在代码中设置这些属性。
关于c++ - 如何更改 Qt Designer 中按钮框内按钮的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2671323/