Is there an easier way to convert from QList<Class*> to QList<QPointer<Class>>?
<p>I have several classes with attributes of the type <code>QList&lt;ClassName *&gt;</code>. I use raw pointers to signal ownership. An accessor for this would return <code>QList&lt;QPointer&lt;ClassName&gt;&gt;</code> since we don't want to hand out raw pointers. The problem is that at the moment every accessor more or less looks like the following:</p>

<pre><code>QList&lt;QPointer&lt;ClassName&gt;&gt; values;
ClassName* value;
foreach(value, m_values){
    values.append(QPointer&lt;ClassName&gt;(value));
}
return values;
</code></pre>

<p>In some cases we use different containers than <code>QList</code> and sometimes the values in the containers are const. Now I wonder if there is a way that doesn't require me to copy/paste this to every accessor because it feels like either there should be a better way or we are doing something wrong in the first place.</p>