Results 1 to 4 of 4

Thread: About painting

  1. #1
    Join Date
    Sep 2006
    Posts
    12
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default About painting

    HI:
    When I painting something on a widget i get such information "QPainter::begin: Widget painting can only begin as a result of a paintEvent" but i get what i want to paint. What does that information mean and how to avoid such information? thanks a lot

  2. #2
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: About painting

    Quote Originally Posted by Pang View Post
    HI:
    When I painting something on a widget i get such information "QPainter::begin: Widget painting can only begin as a result of a paintEvent" but i get what i want to paint. What does that information mean and how to avoid such information? thanks a lot
    According to the document

    Warning: When the paintdevice is a widget, QPainter can only be used inside a paintEvent() function or in a function called by paintEvent(); that is unless the Qt::WA_PaintOutsidePaintEvent widget attribute is set. On Mac OS X and Windows, you can only paint in a paintEvent() function regardless of this attribute's setting.

  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: About painting

    To avoid the problem, u need to override the paintEvent , and do all the painting in that function.

  4. #4
    Join Date
    Aug 2006
    Posts
    44
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: About painting

    You should override paintEvent() and put your drawing code in there. If you need to paint at some arbitrary point in time, and not rely on the more asynchronous nature of QWidget::update(), you can call QWidget::repaint() (choose a reasonable version to avoid repainting the entire window). It sends a paint event to the widget synchronously.

Similar Threads

  1. Painting Problem
    By shyam prasad in forum Qt Programming
    Replies: 3
    Last Post: 5th February 2007, 14:07
  2. Painting and collision detection
    By aamer4yu in forum Qt Programming
    Replies: 1
    Last Post: 18th October 2006, 08:57
  3. Painting lines
    By therealjag in forum Newbie
    Replies: 34
    Last Post: 23rd March 2006, 22:43
  4. Painting to QTextEdit
    By gesslar in forum Qt Programming
    Replies: 8
    Last Post: 18th February 2006, 18:40
  5. Trouble with image painting (QPainter + QImage)
    By krivenok in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2006, 20: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.