我综合以上两位的回复:
1.你指定了parent为this,那么你new出来的widgets会automaticly erased!不用你在delete by hand
2. 你如果想自己删除,你的code应该这么写:
QVector<QLabel*> labelList;
for(int i=1;i<=3;++i)
{
QLabel *a = new QLabel(this);
a->setText("123");
a->move(100*i,0);
labelList<<a;
}
你要人工删除就qDeleteAll(labelList);