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. QT list question
Forum Updated to NodeBB v4.3 + New Features

QT list question

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.1k 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.
  • M Offline
    M Offline
    maybnxtseasn
    wrote on last edited by
    #1

    If i allocate objects and place them inside a list, will the QList perform the deallocation on the objects i dynamically allocate and place in the list when the QList dies?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Blizzard
      wrote on last edited by
      #2

      QList is an array-based list, the array expands automatically, but does not shrink automatically. According to the documentation:

      bq. Note that the internal array only ever gets bigger over the life of the list. It never shrinks. The internal array is deallocated by the destructor and by the assignment operator, when one list is assigned to another.

      You can call the destructor, or create a new QList and add the elements to it, then delete the original QList.

      Software Engineer | Aerospace & Defence

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        [quote author="maybnxtseasn" date="1330232961"]If i allocate objects and place them inside a list, will the QList perform the deallocation on the objects i dynamically allocate and place in the list when the QList dies?[/quote]

        Assuming that you mean having pointers to these objects and place them in QList.
        It depends on the items in your list, but not in general. If you would use QSharedPointer to store in QList, the objects will be destroyed when those references are the last ones.

        Vote the answer(s) that helped you to solve your issue(s)

        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