QVector的内存释放
(2013-01-24 16:37:25)
标签:
qvectorit |
分类: QT |
QVector的内存释放分两种情况:
- 如果T为非指针类型,那么直接使用QVector的clear方法就可以释放内存。代码如下:
typedef struct test_type {int id;Qstring name;QString title;};
QVector<<span style=" color:#800080;">test_type> qVector;...插入数据到qVector中...qVector.clear();
- 如果T为指针类型,直接使用clear方法将不能释放内存。这个时候可以使用void qDeleteAll ( const Container & c )函数来释放所占用的内存。代码如下:
typedef struct test_type {int id;Qstring name;QString title;};
QVector<<span style=" color:#800080;">test_type> qVector;...插入数据到qVector中...qDeleteAll(qVector);
前一篇:Qt 5.0的尝试
后一篇:Qt3D for QT 5