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. Resource management in a Qt class
Forum Updated to NodeBB v4.3 + New Features

Resource management in a Qt class

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 685 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
    manasij7479
    wrote on last edited by
    #1

    I have a Widget class that displays certain information from a file.
    Say, the information can be shown in a QVBoxLayout which contains a number of QLabels depending on the file.
    The class also has a slot which is executed when a new file is opened.
    I want everything currently visible to be discarded and display the information from the new file.

    How do I 'delete' the old objects?
    I can not reuse(QLabel::setText) them, since the number of items will vary.

    When I just call delete the delete operator on them, I get a segfault.
    What is the recommended way of handling this in Qt?

    "Error, no keyboard — press F1 to continue."

    1 Reply Last reply
    0
    • X Offline
      X Offline
      Xander84
      wrote on last edited by
      #2

      it should work if you just remove the root widget of your layout from the view and then invoke the deleteLater() slot maybe?
      Also in the last I had no problem with just deleting a widget that was still visible, but that should be bad practice no matter if that works or not :D

      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