c++ - 如何更改 Qt Designer 中按钮框内按钮的属性?

标签 c++ qt qt4 designer

我在网上查了很久都没有。有谁知道如何访问按钮框中的按钮(使用“右按钮对话框”模板创建)?

最佳答案

在 Designer 中,选择 OKCancel 按钮。然后打开属性编辑器并向下滚动到 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/

相关文章:

c++ - 在启动时关闭 QMainWindow?

qt - 如何检测QT中按下的Alt + Enter

c++ - 从文件中读取可变大小的 2D-STL vector

c++ - dlls : static vs implicit linking, 同样的东西?

c++ - 当我尝试通过 Qt 在 FTP 上获取文件时出错

linux - QUdpSocket 读取 - 使用 tcpdump 观察到偶尔丢失数据报

C++ fstream 多输入文件

c++ - 判断一个数是否为质数

php - 客户端/服务器通信的最佳协议(protocol),从 PHP/Perl 到 C++/Qt4

qt - 使用 Qt 4.8 在全屏模式下隐藏光标?