Dark Star1 Dark Star1 - 1 year ago 102
C++ Question

How do I change properties of buttons within button boxes in Qt Designer?

I have been searching online to no avail. Does anyone know how to access a button in a button box (created using the "Dialog with Buttons Right" template)?

Answer Source

In Designer, select the OK or Cancel button. Then open the property editor and scroll down to the QDialogButtonBox section. You can then expand the standardButtons item to see the various buttons that are available. Other properties, such as the centerButtons property, are also available.

However, designer gives you very little control over the button box.

In code, you can do many other things, such as change the text that appears on the "standard buttons." From the documentation:

findButton = new QPushButton(tr("&Find"));

moreButton = new QPushButton(tr("&More"));

buttonBox = new QDialogButtonBox(Qt::Vertical);
buttonBox->addButton(findButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole);

As long as you give the button box a name in designer, you can set these properties in code.