[Qt-interest] Question regarding pointer parameters in functions

Andreas Pakulat apaku at gmx.de
Fri Jul 3 14:12:43 CEST 2009


On 03.07.09 14:33:32, Patric wrote:
> Yes, ofcourse this is the case when passing widgets to functions. And in  
> that case their memory is managed by the QT parent system.
> If we pass implicitly shared classes to parameters, this will also not be 
> a problem. We assume we are passing the parameter with something like  
> function(new Class());
> But in this case
> void QStandardItemModel::appendRow ( QStandardItem * item )
> if we use this method in the following way :
> appendRow(new QStandardItem("itemText"));
> the result will be undefined.

No the result is not undefined, because a model always takes care of its
content. In particular the standard item model assumes it has ownership of
all its items, thats (IMHO) quite a natural thing to expect from a model
and hence doesn't need explicit documentation.

And in any case, if you're unsure, use the source ;)

Andreas

-- 
Exercise caution in your daily affairs.



More information about the Qt-interest-old mailing list