Results 1 to 13 of 13

Thread: 2 Questions about QPainter

Threaded View

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

    Default Re: 2 Questions about QPainter

    Hi, relating to my question number 1, I've tried different Composition Modes but the result is always the same: the surface where I paint is always cleared, so only appears what I've painted on the last time Here's a simplified version of the code that I use:

    Qt Code:
    1. void FotoEditorFotos::paintEvent(QPaintEvent *event)
    2. {
    3. QPainter painter;
    4. painter.begin(this);
    5.  
    6. if (rectABorrar.isNull())
    7. {
    8. // Paint all the image for the first time centered on the widget
    9. int rectW = arrodonirValor(imatge.width() * escala);
    10. int rectH = arrodonirValor(imatge.height() * escala);
    11. rectFoto.setRect((width() >> 1) - (rectW >> 1), (height() >> 1) - (rectH >> 1), rectW, rectH);
    12.  
    13. painter.drawImage(rectFoto, imatge);
    14. }
    15. else
    16. {
    17. // "rectSeleccio" defines the old position and size (geometry) of the rubberband and needs to be deleted with the original portion of the image, defined by "rectABorrar"
    18. painter.setCompositionMode(QPainter::CompositionMode_Destination);//I don't know if this is the Composition Mode that I should use????
    19. painter.drawImage(rectSeleccio, imatge, rectABorrar);
    20.  
    21. rectABorrar.setRect(-1, -1, 0, 0);
    22. }
    23.  
    24. // Code to Paint the rubberband.........
    25.  
    26. painter.end()
    27. }
    To copy to clipboard, switch view to plain text mode 

    Anybody could tell me where's the mistake? Thanks.
    Last edited by SkripT; 21st February 2006 at 10:27.

Similar Threads

  1. QPainter update()
    By csvivek in forum Qt Programming
    Replies: 5
    Last Post: 24th March 2008, 09:42
  2. Memory management questions (im new to Qt)
    By scarvenger in forum Qt Programming
    Replies: 2
    Last Post: 6th May 2007, 07:41
  3. QPainter and QImage
    By beerkg in forum Newbie
    Replies: 3
    Last Post: 7th September 2006, 14:48
  4. Replies: 7
    Last Post: 20th March 2006, 20:03
  5. Qt related questions and thoughts about getting job
    By AlexKiriukha in forum General Discussion
    Replies: 4
    Last Post: 26th January 2006, 12:25

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
  •  
Qt is a trademark of The Qt Company.