Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Desallocate a QStandardItem [SOLVED]

Desallocate a QStandardItem [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 955 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kevin44115
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved