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. [SOLVED] QVector<*Object> memory
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QVector<*Object> memory

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.9k Views 2 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
    maximus
    wrote on last edited by maximus
    #1

    I am wondering if using .clear() on a QVector of pointers will delete the object associated with the pointer inside the Vector. Or do you have to to this yourself?

    Qt Doc not clear to me :* Removes all the elements from the vector and releases the memory used by the vector.*
    http://doc.qt.io/qt-5/qvector.html#clear

    Thanks


    Free Indoor Cycling Software - https://maximumtrainer.com

    JKSHJ 1 Reply Last reply
    0
    • M maximus

      I am wondering if using .clear() on a QVector of pointers will delete the object associated with the pointer inside the Vector. Or do you have to to this yourself?

      Qt Doc not clear to me :* Removes all the elements from the vector and releases the memory used by the vector.*
      http://doc.qt.io/qt-5/qvector.html#clear

      Thanks

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @maximus said:

      I am wondering if using .clear() on a QVector of pointers will delete the object associated with the pointer inside the Vector. Or do you have to to this yourself?

      You have to do it yourself.

      qDeleteAll() is useful for this: http://doc.qt.io/qt-5/qtalgorithms.html#qDeleteAll

      Qt Doc not clear to me :* Removes all the elements from the vector and releases the memory used by the vector.*
      http://doc.qt.io/qt-5/qvector.html#clear

      That means: Release the memory used to store the pointers.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      1
      • M Offline
        M Offline
        maximus
        wrote on last edited by
        #3

        Thanks for the clarification!


        Free Indoor Cycling Software - https://maximumtrainer.com

        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