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. what should i do when i close a QGraphicsView/Scene with many QGraphicsItems added into the scene
Forum Updated to NodeBB v4.3 + New Features

what should i do when i close a QGraphicsView/Scene with many QGraphicsItems added into the scene

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

    i want to close and open QGraphicsView/Scene dynamically?
    what should i do when i click the close button? should i removeItem, then delete pItem, pItem = NULL in the QGraphicsView/Scene's destructor? or should i do this in QGraphicsView/Scene's closeEvent?
    ps. will QGraphicsItem automatically delete when removeItem from the scene, while when create the QGraphicsItem, no parent was sent to its constructor.
    thank you!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on last edited by
      #2

      "...do when i close a QGraphicsView/Scene..."

      If you mean when you delete scene, all items in the scene will be deleted.
      From the top of the head removeItem does not delete it.
      And you do not need to remove item if you want to delete it.
      Just delete it ( delete item; ) .

      I am pretty sure documentation have more detailed explanation.

      1 Reply Last reply
      0
      • O Offline
        O Offline
        opengpu2
        wrote on last edited by
        #3

        what will happen if i delete an item while it has been added to the scene?
        should i removeItem first, and then delete it?

        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