Results 1 to 5 of 5

Thread: Resource dispose in Qt4

  1. #1
    Join Date
    Jul 2008
    Location
    Poland
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Resource dispose in Qt4

    Hi,

    Could someone explain me, why in the official Qt4 documentation, there is no delete operators?

    Is garbage collector build in Qt4?


    For example, QAction objects are created by new operator, and there are no deconstructor (delete operations).

    http://doc.trolltech.com/4.7-snapsho...plication.html

    Is the reason is to be clean code?

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Resource dispose in Qt4

    There is no garbage collector

    But there is parent-child relationship, objects are organized in hierarchies, and the parent will delete the child when gets out of scope (if created on stack) or manually deleted (if it was created on heap)

  3. #3
    Join Date
    Jul 2008
    Location
    Poland
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Resource dispose in Qt4

    Thank you Zlatomir,

    So, in Qt4 I needn't use shared_ptr class from Boost library, is it?

  4. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Resource dispose in Qt4

    Qt has its own shared pointer, so you can use that.

    And note that only the classes witch derive from QObject have the "parenting" thing, the other (even if their name starts with the letter 'Q') don't have that, so if you allocate on heap you must delete.

  5. #5
    Join Date
    Jul 2008
    Location
    Poland
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Resource dispose in Qt4

    Sorry, post to trash.

Similar Threads

  1. XML resource is garbled?
    By space_otter in forum Qt Programming
    Replies: 8
    Last Post: 22nd June 2010, 01:09
  2. resource file
    By kavinsiva in forum Newbie
    Replies: 4
    Last Post: 18th August 2009, 22:28
  3. Using resource DLL in designer.
    By janEUcitzen in forum Qt Tools
    Replies: 0
    Last Post: 21st March 2009, 08:05
  4. Resource file in Qt4.4.0
    By jml in forum Qt Tools
    Replies: 0
    Last Post: 6th May 2008, 18:01
  5. QLocale/Resource
    By coderbob in forum Newbie
    Replies: 4
    Last Post: 21st November 2007, 20:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.