title: Qt smart pointers in function parameters
body: <p>I'm looking for best practices with Qt smart pointers. Let's say I have something like this.</p>
  
  <pre><code>void aFunction() {
      QSharedPointer&lt;QVector&lt;QSharedPointer&lt;Object&gt; &gt; &gt; pointer = QSharedPointer&lt;QVector&lt;QSharedPointer&lt;Object&gt; &gt; &gt;(new QVector&lt;QSharedPointer&lt;Object&gt; &gt;);
  
      doSomethingWithPointer(pointer);
      changeOwnership(pointer);
  }
  </code></pre>
  
  <p>Then in doSomethingWithPointer function</p>
  
  <pre><code>void doSomethingWithPointer(QSharedPointer&lt;QVector&lt;QSharedPointer&lt;Object&gt; &gt; &gt; pointer) {
      pointer-&gt;append(QSharedPointer&lt;Object&gt;(new Object);
  }
  </code></pre>
  
  <p>Now I after doSomethingWithPointer, I pass the pointer to changeOwnership, which should take ownership of it. What I'm wondering about is doSomethingWithPointer. Is it okay to pass shared pointers in a function like that? Or should I maybe use a QWeakPointer since doSomethingWithPointer doesn't actually take ownership of pointer? When exactly should I use QWeakPointer?</p>