Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Desallocate a QStandardItem [SOLVED]



  • Hello,

    I would like to desallocate a QStandardItem but it doesn't work.

    This is my code:

    @QStandardItem *qsItem = new QStandardItem(QIcon::QIcon(QString::fromStdString(sImage)),this->sNom.c_str());
    qsItem->appendRow(new QStandardItem(""));
    qsModel->appendRow(qsItem);
    delete qsItem;@

    It's work when I don't delete the qsItem.
    I think they have a memory leak, isn't it ?
    Does Qt automaticaly a delete of all Item in a Model when the application Stop ?


  • Lifetime Qt Champion

    Hi,

    The model takes ownership of the item. Don't delete it that way


Log in to reply