title: How to initialize QVector
body: <p>I am new to c++ and Qt and I am trying to initialize a QVector, which is a class member in a class initialization list like:</p>
  
  <pre><code>MyClass::MyClass(QWidget *parent) : QMainWindow(parent) , myVector(QVector&lt;double&gt;(100))
  </code></pre>
  
  <p>I was expecting the QVector to have already 100 indexes alocated, but when I try to read <code>myVector[0]</code> I get an assertion error saying "Unhandled exception at 0x0143bf77 in test.exe: 0xC0000005: Access violation reading location 0x00000004." and the program stops at this line of Qt: </p>
  
  <pre><code>inline T &amp;QVector&lt;T&gt;::operator[](int i)
  { Q_ASSERT_X(i &gt;= 0 &amp;&amp; i &lt; d-&gt;size, "QVector&lt;T&gt;::operator[]", "index out of range");
    return data()[i]; }
  </code></pre>
  
  <p>Which I believe shows that I am trying to access members that arent allocated yet, so I guess I am not using the initialization list properly. I could make it a pointer and make a <code>new QVector(100)</code> in the constructor but I want to learn what's wrong and how may I make it correct.</p>