How do I dynamically allocate memory for arrays in Qt C++? -


There are some problems for allocating memory to ARP I doing:

  Int dx = 5; QPoint * qPoint; QPoint = new QPoint [dx + 1];  

However, when I try to debug the code, the program only crashes when it tries to execute the third line .... any clue?

If you want to use the Qt SDK properly, then you should use C ++ array or STD array Instead of using QVector. Whether you can use QVector as an indicator, it does not really matter, because it will internally dynamically allocate memory. For example:

  int dx = 5; QVector & LT; QPoint & gt; Points; Points. Position (dx + 1);  

You can also:

  QVector & lt; QPoint & gt; * Points = new conector & lt; QPoint & gt; (DX + 1);  

If you want vector as an indicator but use the built-in memory sharing for Qt vectors so that you can use the approach most time ago.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -