所以我有一个叫做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();
它会取消分配我分配的所有内存吗?
谢谢.