[bt-devel] Icons and buttons

Gary Holmlund gary.holmlund at gmail.com
Tue Apr 7 19:18:01 MST 2009


Eeli Kaikkonen wrote:
> On Tue, 7 Apr 2009, Jonathan Marsden wrote:
>   
>> I haven't played with this myself, but isn't Qt itself already
>> localized?  Surely you should not be required to use "your own" buttons
>> just to get text on them in the appropriate interface language?!
>>     
>
> Qt may be localized, but the problem is that we can't be sure that it's
> localized for all languages we need. At least for me the current Windows
> package starts with Finnish interface but has English buttons here and
> there. I don't like it at all.
>
> Using "our own" buttons is not a problem. We just change the text and
> add an icon. With a proper helper function (not necessarily a subclass!)
> it's actually easier than creating Qt buttons "manually". If we want to
> use icons at all, we have to add them for every button anyways.
>   
Here is what Qt says about it.  It is not very satisfying. The 
qt_untranslated.ts file they mention is in the source tar file, but not 
in the final installation of Qt. It also has about 1400 strings.
http://www.qtsoftware.com/developer/faqs/faq.2008-05-06.6265952148

It is good to use QDialogButtonBox because the location of various 
buttons changes with the Qt style (gnome, kde, mac, win, etc.). 
QDialogButtonBox takes care of this detail. There is more than one way 
to add buttons to it. Here is one of the recommended ways from the Qt doc:

-------

     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.

Gary





More information about the bt-devel mailing list