Results 1 to 3 of 3

Thread: QIcon::QIcon(), QPixmap::setAlphaChannel(), and input parameter ownership

  1. #1
    Join Date
    Feb 2006
    Posts
    22
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QIcon::QIcon(), QPixmap::setAlphaChannel(), and input parameter ownership

    Does QIcon::QIcon( const QPixmap & pixmap ) take ownership of its input parameter, pixmap?
    Does QPixmap::setAlphaChannel( const QPixmap & alphaChannel ) take ownership of its input parameter, alphaChannel?

    In other words, for ...
    Qt Code:
    1. QPixmap * pPixmap;
    2. QBitmap * pBitmap;
    3. QIcon * pIcon;
    4.  
    5. pPixmap = <pointer to image previously read in>;
    6.  
    7. pBitmap = new QBitmap( * pPixmap );
    8.  
    9. P.begin( (QPaintDevice *) pBitmap );
    10. // painting here
    11. P.end();
    12.  
    13. pPixmap->setAlphaChannel( * pBitmap );
    14.  
    15. pIcon = new QIcon( * pPixmap );
    16.  
    17. ...
    18.  
    19. delete pIcon;
    To copy to clipboard, switch view to plain text mode 
    ... does the delete statement also delete the Pixmap and/or the Bitmap?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QIcon::QIcon(), QPixmap::setAlphaChannel(), and input parameter ownership

    Quote Originally Posted by mule
    Does QIcon::QIcon( const QPixmap & pixmap ) take ownership of its input parameter, pixmap?
    Does QPixmap::setAlphaChannel( const QPixmap & alphaChannel ) take ownership of its input parameter, alphaChannel?
    No they don't. Both of these parameters are references to a constant object, which means that those methods can't destruct these objects (not mentioning making any other changes in their internal state).

    Quote Originally Posted by mule
    In other words, for ... does the delete statement also delete the Pixmap and/or the Bitmap?
    No, it does not delete those objects. QIcon doesn't even know that pPixmap is a pointer.

  3. #3
    Join Date
    Feb 2006
    Posts
    22
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QIcon::QIcon(), QPixmap::setAlphaChannel(), and input parameter ownership

    Thank you very much, jacek.

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.