Results 1 to 5 of 5

Thread: implicit or shared copy?

  1. #1
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question deep or shallow copy?

    hi all, I would like to know if the result of the operation:
    Qt Code:
    1. QImage im2 = im1.scaledToWidth(245);
    To copy to clipboard, switch view to plain text mode 
    Generates a deep copy or a shallow copy? The operator= of Qimages generates shallow copies but i'm not sure in the case of the operation above. Thanxs.
    Last edited by SkripT; 17th February 2006 at 12:26.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    85
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: implicit or shared copy?

    scaledToWidth creates a copy of your image.

  3. #3
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: implicit or shared copy?

    Quote Originally Posted by Codepoet
    scaledToWidth creates a copy of your image.
    Yes I know, the question is if this copy is a deep copy or a shallow copy?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    85
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: implicit or shared copy?

    It has to be a deep copy because the underlying data was newly created:
    Qt Code:
    1. QImage temp = im.scaledToWidth(...);// deep copy
    2. scaledImage = temp;// shallow copy
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: implicit or shared copy?

    That's exactly what I expected

Similar Threads

  1. Replies: 1
    Last Post: 27th November 2014, 09:11

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.