Results 1 to 11 of 11

Thread: QPainter ouside of paintEvent with a pixmap

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QPainter ouside of paintEvent with a pixmap

    I'm porting a Qt 3.3.2 application to Qt 4.1.1

    In Qt 3 you can create a QPainter p(&pixmap) and paint to the pixmap anywhere in the code.

    In Qt 4 it says that all painting must take place inside the paintEvent.

    Why is that the following will work in Qt 4 outside of paintEvent

    Qt Code:
    1. void someFunc()
    2. {
    3. Pixmap pix(size());
    4. pix.fill(this, 0, 0);
    5. QPainter p(&pix); // no error
    6. // paint away
    7. }
    To copy to clipboard, switch view to plain text mode 

    but, the following will not.

    Qt Code:
    1. // here ptrPix was filled by another function
    2. void someFunc()
    3. {
    4. QPainter p(ptrPix); // QPainter::begin(), paintdevice returned engine == 0, type: 2
    5. // paint away
    6. }
    To copy to clipboard, switch view to plain text mode 

    am i missing a concept here?

    I will move all of my painting to the paintEvent so that I can take advantage of the double buffering built in to Qt 4, I just want to know what is going on with the above statements.

    Thanks.
    Last edited by bitChanger; 21st March 2006 at 20:46.

Similar Threads

  1. QPainter reuse within a paintEvent
    By Micawber in forum Qt Programming
    Replies: 2
    Last Post: 2nd May 2008, 16:51
  2. Replies: 12
    Last Post: 5th February 2006, 10:34

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.