[bt-devel] Icons and buttons
    Eeli Kaikkonen 
    eekaikko at mail.student.oulu.fi
       
    Tue Apr  7 23:14:08 MST 2009
    
    
  
Quoting Gary Holmlund <gary.holmlund at gmail.com>:
> -------
>
>     There are a couple ways of using QDialogButtonBox. One ways is to
>     create the buttons (or button texts) yourself and add them to the
>     button box, specifying their role.
>
>     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);
>
> -----
> This seems like the best way to do it.
>
I don't remember the different ways I have used QDialogButtonBox, but  
I suppose it's easier to do:
b = QDialogButtonBox(QDialogButtonBox::Cancel, QDialogButtonBox::Ok);
util::prepareButtonBox(b);
than to create to buttons manually with tr() and icons. If this kind  
of OK/Cancel dialog is used in 5 places, we have to add 10 tr() and 10  
icon names. This can be automated by using a helper function which  
just finds some standard buttons from the buttonbox and sets new  
string and icon. This saves also work of translators 'cause there's  
only 1 tr("Cancel") instead of 5. (I would also add a comment to tr()).
Nonstandard or rare button names/icons must be still added manually.
--Eeli Kaikkonen
    
    
More information about the bt-devel
mailing list