PDA

View Full Version : QDialogButtonBox buttons size



hulud
14th June 2011, 09:01
In my program i am dinamically inserting buttons into a QDialogButtonBox, but i want them to be really big.
No matter what i try to do, they are always standard size.
can someone point me to a correct stylesheet or anything to achive that?

right now i'm inserting new buttons like that:

ui->buttonBox->addButton("OK", QDialogButtonBox::AcceptRole);
ui->buttonBox->addButton("Yes", QDialogButtonBox::YesRole);
ui->buttonBox->addButton("No", QDialogButtonBox::NoRole);

Santosh Reddy
15th June 2011, 06:26
Think again why you want to use QDialogButtonBox, QDialogButtonBox is generally used for platform specific look and feel, if you change the buttons layout / sizes, the basic purpose of platform specific is lost. I would recommend to have you own custom QDialog, and add buttons to it.

Ok, as far as QDialogButtonBox is concerned, it has its own size constrains (as is a QWidget by itself). So you need to set the size of ButtonBox first and then set size all the child buttons in it, something like this


buttonBox->setMinimumHeight(100);
QList<QAbstractButton *> buttons = buttonBox->buttons();
while(buttons.size())
buttons.takeFirst()->setMinimumHeight(buttonBox->minimumHeight());