[Qt-interest] A new (?) const-correct way to create aUiobjectand do setupUi
Niels Dekker (Qt-interest)
mymailfromqt at xs4all.nl
Tue Feb 8 19:00:47 CET 2011
Robert Hairgrove wrote:
> Thiago Macieira wrote:
>> Em terça-feira, 8 de fevereiro de 2011, às 18:19:07, Robert Hairgrove
>> escreveu:
>>> Even if I could call non-const functions on the pointer members of
>>> the const ui object, as Thiago has pointed out (no pun intended!), I
>>> wouldn't be able to call retranslateUi() on the object after
>>> creation which would mean that if my application allows the user to
>>> switch languages dynamically, it wouldn't work unless that function
>>> were declared const.
>>>
>>> That's a limitation I wouldn't want to live with.
>>
>> That actually means retranslateUi should be a const function.
>
> Yes. :)
>
> Is there anything that speaks against it?
Well, conceptually one might consider retranslation of the Ui a non-const
operation.
Anyway, I wouldn't mind if a function like createAndSetupUi would return a
non-const reference. Leaving it up to the user whether the ui member
variable is a const, or a non-const reference.
My 2 cents,
Niels
More information about the Qt-interest-old
mailing list