android list.clear()是否将对象都清理回收了,c-QList clear函数调用是否清除存储在QList中的动态分配对象的内存?...

在Qt环境中,创建了一个AppointmentSchedule类,并在外部类中使用QList存储动态分配的对象。通过QList的clear()函数,可以释放QList中的所有对象引用,但不会直接删除对象本身。对象的内存需要通过显式调用delete来释放。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

所以我有一个叫做AppointmentSchedule的类,它是以下类型:

namespace Ui {

class AppointmentSchedule;

}

class AppointmentSchedule : public QWidget

{

Q_OBJECT

public:

explicit AppointmentSchedule(QWidget *parent = 0);

~AppointmentSchedule();

Ui::AppointmentSchedule *ui;

};

此类的ui包含两个QLabel类型的对象和两个QDateTimeEdit类型的对象.在外部类中,我需要具有动态分配对象类型为AppointmentSchedule的QList.我将通过以下方式将动态分配的对象附加到QList中.

QList scheduleList;

foreach (QDate date, dates)

{

AppointmentSchedule * newSchedule = new AppointmentSchedule(this);//Allocation of memory

QDateTime sDateTime(date, QTime(8, 0, 0));

newSchedule->ui->appointmentStartDateTimeEdit->setDateTime(sDateTime);

QDateTime eDateTime(date, QTime(8, 15, 0));

newSchedule->ui->appointmentEndDateTimeEdit->setDateTime(eDateTime);

scheduleList.append(newSchedule);

}

如果我像这样调用QList的clear()函数:

scheduleList.clear();

它会取消分配我分配的所有内存吗?

谢谢.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值