Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    [SOLVED] extending QWebView to post process/filter the web page

    General and Desktop
    2
    4
    1082
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      pmh4514 last edited by

      so I know how to extend QWebView and to override paintEvent if I wanted to draw something completely different.
      But instead, I want to grab the content of the web-view (or whatever widget for that matter) - do something to it (ie. filter/process) and then display the result instead of what would have been drawn had I not overridden it... but I find that if I do any of the QWidget grabbing functions within paintEvent, I get recursion and crashes.

      What's the right way?

      1 Reply Last reply Reply Quote 0
      • P
        pritamghanghas last edited by

        Have a look at QWidget::render() function. you can use that function to get the rendering a pixmap, process it and paint it into widgets rectangle.

        1 Reply Last reply Reply Quote 0
        • P
          pmh4514 last edited by

          I tried using render() as below, but only get a black image (and it seems like render() actually calls into paintEvent as well.

          @
          QPixmap pixmap(size());
          QPainter painter;

          painter.begin(&pixmap);
          this->render(&painter);
          painter.end();

          // processing/filtering would go here.

          painter.begin(this);
          painter.drawPixmap(0, 0, pixmap);
          painter.end();
          @

          1 Reply Last reply Reply Quote 0
          • P
            pmh4514 last edited by

            I did end up getting this to work by using two widgets.. I extended QWebView and overrode paintEvent to grab the widget and process it, and a second QFrame, occupying the same visual space, with transparent to mouse/keyboard events, extended to override paintEvent to draw the QImage as saved by the QWebView.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post