Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] extending QWebView to post process/filter the web page

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.3k Views
  • 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 Offline
    P Offline
    pmh4514
    wrote on last edited by
    #1

    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
    0
    • P Offline
      P Offline
      pritamghanghas
      wrote on last edited by
      #2

      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
      0
      • P Offline
        P Offline
        pmh4514
        wrote on last edited by
        #3

        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
        0
        • P Offline
          P Offline
          pmh4514
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved