if you use QVector<> it will handle all this stuff for you.