Results 1 to 3 of 3

Thread: QImage deconstructor or delete / proper usage

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    520
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 77 Times in 75 Posts

    Default Re: QImage deconstructor or delete / proper usage

    Hi, if you use a pointer, you need to use image->setPixel().
    But your original code should not create a memory leak because the QImage is created on the stack and gets destroyed once the method myClass:aint() is left.

    Ginsengelf

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,348
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: QImage deconstructor or delete / proper usage

    I'll make a pretty good bet that it is the "do stuff here" code that causes the memory leaks unless

    Qt Code:
    1. image = new QImage(width, height, QImage::Format_RGB32);
    To copy to clipboard, switch view to plain text mode 

    this code also ended up inside the paint() method.

Similar Threads

  1. Proper way to delete a QMap
    By jano_alex_es in forum Newbie
    Replies: 4
    Last Post: 28th February 2020, 18:31
  2. Proper QList usage
    By smick in forum Newbie
    Replies: 3
    Last Post: 25th September 2011, 16:51
  3. QSqlQuery prepared statements proper usage
    By psih128 in forum Qt Programming
    Replies: 5
    Last Post: 12th April 2011, 00:10
  4. Proper QList usage
    By space_otter in forum Newbie
    Replies: 5
    Last Post: 22nd June 2010, 07:57
  5. Replies: 1
    Last Post: 13th November 2009, 02:45

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
  •  
Qt is a trademark of The Qt Company.