Results 1 to 20 of 21

Thread: How to create my own QPixmap Or QImage

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    33
    Qt products
    Qt4
    Platforms
    MacOS X

    Default How to create my own QPixmap Or QImage

    Hi,

    I want create my own QPixmap or QImage using my own data. so that I able to set this QPixmap to QLabel instead of drawing the same content again and again in paintEvent()

    Thanks & Regards

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to create my own QPixmap Or QImage

    Qt Code:
    1. QPixmap pix;
    2. QPainter p(&pix);
    3. p.drawXYZ();
    4.  
    5. lablel->setPixmap(pix);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to create my own QPixmap Or QImage

    Quote Originally Posted by MrDeath View Post
    Qt Code:
    1. QPixmap pix;
    2. QPainter p(&pix);
    3. p.drawXYZ();
    4.  
    5. lablel->setPixmap(pix);
    To copy to clipboard, switch view to plain text mode 
    One mistake.. always specify a size for the pixmap / image while creating it.
    Something like - QPixmap pix(600,480);
    You cannot paint on null pixmap !!

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to create my own QPixmap Or QImage

    Quote Originally Posted by aamer4yu View Post
    One mistake..
    That was not a mistake. That was left as an exercise for the reader.

    always specify a size for the pixmap / image while creating it.
    Something like - QPixmap pix(600,480);
    You cannot paint on null pixmap !!
    You PASSED!!

Similar Threads

  1. Replies: 5
    Last Post: 17th May 2009, 20:02
  2. drawing on a QPixmap or QImage
    By gren15 in forum Newbie
    Replies: 15
    Last Post: 3rd March 2009, 17:48
  3. DIB to QImage or QPixmap
    By ^NyAw^ in forum Qt Programming
    Replies: 0
    Last Post: 8th August 2008, 20:18
  4. What's faster: QPixmap-to-QImage or QImage-to-QPixmap
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 15th December 2006, 17:11
  5. QImage or QPixmap?
    By Dark_Tower in forum Qt Programming
    Replies: 9
    Last Post: 1st April 2006, 17:08

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.