dboddie at trolltech.com
Wed Feb 11 17:49:48 GMT 2009
On Wednesday 11 February 2009, Giovanni Bajo wrote:
> On 2/11/2009 6:24 PM, David Boddie wrote:
> > To avoid problems, I have previously defined a helper method in subclasses
> > where I thought it was necessary, like this:
> > class ActionEditorWidget(QLabel):
> > def tr(self, text):
> > return qApp.translate("ActionEditorWidget", text)
> I don't see what this code is supposed to help.
> The problem at hand occurs when you use self.tr() in a class that you
> later inherit. I don't see how redefining tr() in the base class is
> going to help.
Good point. Usually I don't use it at all, but I seem to remember that I
wanted to enforce the C++ behaviour referred to in the Reference Guide:
If you want to use a different set of translations in the subclass, you'll
get the behaviour you want by just calling self.tr() without creating any
helper methods. You won't inherit any translations, though, or will you?
More information about the PyQt