Results 1 to 2 of 2

Thread: QPainter above already painted

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QPainter above already painted

    Hi,

    I'm trying to use QPainter inside a QGLWidget to draw images and rectangles, circles, ... using OpenGL backend.

    First I display an image using a QPainter and painting a QPixmap.
    Then I paint a rectangle using a QPainter and painting it.

    The problem is that the second painting clears the image(normal behaviour as I can read).

    I can't store the image to repaint it adding the other elements so I want to keep the already painted elements to not be cleared.

    Is there anyway to paint above what is already painted?

    From Qt doc, it says that QPainter can only be used inside the paintEvent when the PaintDevice is a Widget(this is the case), but I'm using it outside the paintEvent without problem.

    Thanks,
    Last edited by ^NyAw^; 26th February 2014 at 15:17.
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPainter above already painted

    Quote Originally Posted by ^NyAw^ View Post
    From Qt doc, it says that QPainter can only be used inside the paintEvent when the PaintDevice is a Widget(this is the case), but I'm using it outside the paintEvent without problem.
    That just refers to painting on a widget. The only place you can paint on a widget is in its paintEvent() method. You can use QPainter on any other QPaintDevice whenever you want as long as there are no other restrictions on the given paint device. E.g. you can only paint on a QPixmap from within the main/GUI thread.

    Cheers,
    _

Similar Threads

  1. Removing last Painted point
    By ebsaith in forum Qt Programming
    Replies: 10
    Last Post: 2nd July 2013, 10:37
  2. dialog content is not painted
    By miso in forum Qt Programming
    Replies: 7
    Last Post: 12th March 2013, 14:12
  3. QDialogButtonBox text not painted
    By kshi in forum Qt Programming
    Replies: 0
    Last Post: 8th January 2011, 00:41
  4. Replies: 5
    Last Post: 20th October 2009, 07:18
  5. Widget not painted properly
    By qwakaw in forum Qt Programming
    Replies: 0
    Last Post: 11th November 2008, 11:30

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.