Results 1 to 7 of 7

Thread: How to distinguish paint events

  1. #1

    Question How to distinguish paint events

    Hi all,

    When i override the paintEvent of QWebView which inherts QWidget, i found that the paintEvent was consecutively called twice before the widget is shown on screen.
    So my question is how to distinguish these two events, anybody help? Thanks!

    Btw, i found the first event drawing the background, while the second rendering DOM elements of the webpage, using the same paintEvent.
    Last edited by naruto_9w; 17th January 2009 at 15:00.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: How to distinguish paint events

    Why would you want to distinguish those paint events?

  3. #3

    Default Re: How to distinguish paint events

    Quote Originally Posted by wysota View Post
    Why would you want to distinguish those paint events?
    I wanna get the DOM painting and call *setMask* method in the second paint event to create a web view with transparent background on screen.

    The story is told in this thread. Thanks!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: How to distinguish paint events

    Don't do that. PaintEvent is for painting and painting only. If you need to do anything else, do it elsewhere (in showEvent() maybe?).

  5. #5

    Default Re: How to distinguish paint events

    Quote Originally Posted by wysota View Post
    Don't do that. PaintEvent is for painting and painting only. If you need to do anything else, do it elsewhere (in showEvent() maybe?).
    I know that is a not elegant way, but how to catch the exact painting contents of webpage if do not hack the paint event, showEvent is invoked before these two paint event, and *frame->render(...)* is called in paintEvent, but during my step-by-step debugging, i tried in vain to find the reason why paintEvent are called twice from the call stack, any hints for that? Thanks.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: How to distinguish paint events

    Quote Originally Posted by naruto_9w View Post
    I know that is a not elegant way, but how to catch the exact painting contents of webpage if do not hack the paint event
    By calling QWidget::render().

  7. #7
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to distinguish paint events

    I didn't read everything carefully, but isn't handling QEvent::PolishRequest the intended way to initialize your content.

    Uwe

Similar Threads

  1. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 15:03

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.