Important: Please read the 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(""));
    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


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

Log in to reply