Results 1 to 3 of 3

Thread: partial repaint

  1. #1
    Join Date
    Apr 2009
    Posts
    21
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default partial repaint

    I override the paint() method of a QGraphicsWidget subclass with a background color and some text label in the middle. For every second I use a timer to change the background color but keep the same text, or keep the same bg color but change the text. Is there a way for me to do this without having to repaint both of the components, i.e. only text or background color but not both? I'm using QtEmbedded 4.5.

    I guess one way would be having 2 separate widgets but since their space overlap each other, it's just cleaner to use one single widget.

    All suggestions are appreciated.
    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: partial repaint

    Well, basically you do a composition of two layers: Background and text. You can of course keep the upper layer in a pixmap with alpha channel. But I doubt that the compositing of the final image from that second layer will be faster than the font rendering. Font rendering is heavily optimized on modern windowing systems. Also if you use a single background color, filling a rect will be very fast compared to blitting a cache image.
    It's nice to be important but it's more important to be nice.

  3. The following user says thank you to axeljaeger for this useful post:

    cookie1909 (19th August 2009)

  4. #3
    Join Date
    Apr 2009
    Posts
    21
    Thanks
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: partial repaint

    hmm, first I thought by achieving partial repaint would help the performance. But I just found out that if my paint() function is empty, and whenever the timer expires, I would call QGraphicsItem::update(boundingRect()); which practically would have nothing to repaint for that area. And it still takes almost 10% of the CPU. Any idea why it's acting like that?

    Thanks.

Similar Threads

  1. repaint a cell or row in QTableWidget
    By alphaqt in forum Newbie
    Replies: 6
    Last Post: 26th June 2012, 12:21
  2. QPushButton not calling repaint when needed?
    By Enygma in forum Qt Programming
    Replies: 5
    Last Post: 13th May 2010, 18:03
  3. repaint issue in qt4
    By ancest in forum Qt Programming
    Replies: 2
    Last Post: 12th March 2009, 10:51
  4. Using QGraphicsView as a Splash Screen (repaint issues)
    By chezifresh in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2008, 22:22
  5. force repaint
    By georgie in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2006, 14:16

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.