[Qt-interest] A new (?) const-correct way to create a Ui object and do setupUi
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Tue Feb 8 12:50:04 CET 2011
On 2011-02-08 Thiago Thiago Macieira wrote:
>> ..
>> Protecting the Ui object against any accidental modifications!
But it would also prevent me from doing *intentional* changes, such as changing the visibility dynamically of a given UI element ;) As someone else already noted.
> Why a reference? What's the advantage here?
Personally I use references as to indicate this instance HAS to be there - otherwise the application logic would not work here. In the given instance it absolutely does not make sense to have e.g. a QMainWindow without its corresponding Ui definition, so the Ui instance HAS to be there. And that was probably the OP's intention, to express the fact that a widget without proper Ui part totally does not make sense.
A pointer for me has always something "optional", so when a method argument is a pointer for me it carries along the meaning "you may pass 0 here and everything will be fine!". The same for return arguments: "This return value might be 0".
Again, this is just a personal "very general rule of thumb" with dozens of exceptions ;)
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list