Whenever I run my code I get an error stating the vector went out of bounds. The vector is declared as

Qt Code:
  1. QVector <CCell> grid;
To copy to clipboard, switch view to plain text mode 
in a class, where CCell is just a class which contains a couple functions for setting its values.

So in this class that the vector is declared, I initialize it with
Qt Code:
  1. resize(width * height);
To copy to clipboard, switch view to plain text mode 

So after breaking pointing the vector gets sized correctly to the value 600 (30 * 20).
So after investigating where this would error out it is this code here immediately from the constructor:

Qt Code:
  1. void CGrid::clearMap()
  2. {
  3. int i = 0;
  4. int j = 0;
  5.  
  6. for(i = 0; i < width; i++)
  7. {
  8. for(j = 0; j < height; j++)
  9. {
  10. grid[i * width + j].setCellVal(0);
  11. }
  12. }
  13. }
To copy to clipboard, switch view to plain text mode 

for whatever reason when following this in breakpoints, j immediately is initialized to 0, then after going through the first for loop, it jumps immediately to 20 (or whatever the height value is), immediately throwing it out of bounds for the vector.
I have no code that changes this value to 20 or interacts with it, so there is no way that I can think of for it to do this.

Any ideas? I'm using the QtCreator 3 IDE with MSVC2010 compiler.