Results 1 to 2 of 2

Thread: QImage declaration and intitialization?

  1. #1
    Join Date
    May 2018
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QImage declaration and intitialization?

    If I declare a pointer to a QImage I can do this:

    Qt Code:
    1. QImage *myImage;
    2.  
    3. //and later..
    4.  
    5. myImage = new QImage(800,800,QImage::Format_ARGB32)
    To copy to clipboard, switch view to plain text mode 

    And if I declare a QImage with the default constructor, it will give me a null QImage and I can do this:
    Qt Code:
    1. QImage myImage;
    2. //and later
    3. myImage.load(file);
    To copy to clipboard, switch view to plain text mode 

    Is there any way to declare a QImage and later set it up as 800,800,QImage::Format_ARGB32 ?

  2. #2
    Join Date
    May 2018
    Posts
    13
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QImage declaration and intitialization?

    This seems to work but it seems conflated:
    Qt Code:
    1. QImage myImage;
    2. QImage *temp = new QImage(800,800,QImage::Format_ARGB32);
    3. myImage = *temp;
    To copy to clipboard, switch view to plain text mode 

    There is no QImage function to do this? Also, lets say myImage was not a null QImage, but an actual image in a class . Assigning a new image to it, does that create a memory leak or does QImage take care of that? I come from Java and the system takes care of all orphaned objects.
    Last edited by shawnlau; 29th June 2018 at 01:28.

Similar Threads

  1. DOM declaration
    By Lozee in forum Qt Programming
    Replies: 1
    Last Post: 18th September 2014, 12:48
  2. constructor declaration
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 6th July 2011, 09:00
  3. static declaration
    By jhearon in forum Qt Programming
    Replies: 1
    Last Post: 18th February 2008, 21:37
  4. QtXml: xml declaration
    By Gopala Krishna in forum Newbie
    Replies: 1
    Last Post: 2nd June 2007, 12:12
  5. Replies: 3
    Last Post: 15th March 2006, 11:44

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.