Results 1 to 2 of 2

Thread: update of the child widget causes paintEvent() of the parent widget to be called

  1. #1

    Question update of the child widget causes paintEvent() of the parent widget to be called

    Dear all,

    I have a full screen main window P (parent widget) showing an image using paintEvent(). A child widget C is attached to this main window and calling its own update() periodically. It seems that once the update() of C is called, the paintEvent() of P gets called as well, which consumes a lot of CPU (on Ubuntu X11).

    Because C may have (semi-) transparent colors, I cannot set Qt::WA_OpaquePaintEvent attribute for it. Is there any other way to prevent calling P's paintEvent() or to reduce the CPU consumption substantially?

    Thanks in advance for any suggestions.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: update of the child widget causes paintEvent() of the parent widget to be called

    Since your C has a semi-transparent background, the parent has to be painted first prior to painting the child. In some cases Qt will take the background from its backing store, in some it will call the paint event of the parent. If you optimize the paint event of the parent and only paint the part which is requested, the overhead should be small.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 16th February 2011, 13:59
  2. child widget resize to parent widget
    By bobFromAccounting in forum Newbie
    Replies: 10
    Last Post: 11th February 2011, 02:53
  3. Replies: 7
    Last Post: 14th January 2010, 08:47
  4. Replies: 4
    Last Post: 3rd October 2009, 08:19
  5. How to move child widget with parent widget?
    By anupamgee in forum Qt Programming
    Replies: 3
    Last Post: 19th June 2009, 15:23

Tags for this Thread

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.