title: Qt: function returns object, putting it into a pointer
body: <p>Hopefully this isn't too stupid but I want to make sure I'm doing this right.</p>
  
  <p>Some Qt functions return Qt objects as values, but we may want to store them in a pointer somewhere.  For example, in QDomDocument, the function documentElement returns a QDomElement, not a pointer to it.  Now, as a member of my class I have:</p>
  
  <pre><code>QDomElement *listRootElement;
  </code></pre>
  
  <p>In a function that sets things up I am using this:</p>
  
  <pre><code>listRootElement = new QDomElement;
  *listRootElement = mainIndex-&gt;documentElement();
  </code></pre>
  
  <p>(mainIndex is a QDomDocument.)</p>
  
  <p>This seems to work, but I just want to make sure I'm doing it right and that nothing will come back to bite me.</p>
  
  <p>It would be very similar for some of the image functions where a QPixmap might be returned, and I want to maintain pointers to QPixMap's.</p>
  
  <p>Thanks for any comments!</p>