Results 1 to 4 of 4

Thread: how to save somtihing drawed on QPaiter to an image?

  1. #1
    Join Date
    Dec 2006
    Posts
    36
    Thanked 1 Time in 1 Post

    Default how to save somtihing drawed on QPaiter to an image?

    I draw something like line, arc ,eclipse etc on QPaiter ,NOw I want to save them in an image.But how to do it? can anybody help me ?

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to save somtihing drawed on QPaiter to an image?

    You will need to specify the paint device for the QPainter

    Something like

    Qt Code:
    1. QPixmap pm(width,height);
    2. QPainter painter(&pm);
    3. ....
    4. ....
    5. //Your drawing code
    6. ....
    7. pm.save(filename,format);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Dec 2006
    Posts
    36
    Thanked 1 Time in 1 Post

    Default Re: how to save somtihing drawed on QPaiter to an image?

    thanks for reply soon. YES, what you said can pait them to an image .but there comes another problem, which will not show on paiter widget . I Want to show them on a widget, but at the same ,i can save to an image file.

    why QPAINTER not provide the save function ? just like delphi TCANVAS ?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to save somtihing drawed on QPaiter to an image?

    QPainter can paint on a single QPaintDevice at time. You can use QPainter::setRedirected() to redirect the painting to another device. But maybe QPixmap::grabWidget() is more like what you're after?
    J-P Nurmi

Similar Threads

  1. Replies: 7
    Last Post: 12th August 2006, 15:11
  2. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36

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.