tags:

views:

78

answers:

1

I have been searching online now to no avail, but does anyone know how to access a button in a button box ?(created using the "Dialog with Buttons right" template)

+1  A: 

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"));
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);

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

Kaleb Pederson
I'm guessing the code for the form is generated and stored in some file so I can go into that file and change the button properties that I need to?
Dark Star1
Don't edit the generated file. There's different ways of working with the generated code documented on the [Creating and Using Components for Qt Designer](http://doc.trolltech.com/4.6/qtdesigner-components.html) page.
Kaleb Pederson