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. Does using QPainter to "copy" a canvas embedded in QWebView copy or share memory?
Qt 6.11 is out! See what's new in the release blog

Does using QPainter to "copy" a canvas embedded in QWebView copy or share memory?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 754 Views 1 Watching
  • 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

    I have a QWebView loaded with an HTML page that has a canvas element called canvas0. (The embedded canvas occupies the entire viewport)

    When I do the following, is there a full copy operation happening under the hood or does this share memory?

    @
    QWebElement el = page()->mainFrame()->findFirstElement("#canvas0");

    QImage image(el.geometry().width(), el.geometry().height(), QImage::Format_ARGB32);
    QPainter painter(&image);
    el.render(&painter);
    painter.end();
    

    @

    I'm doing that so that I can then use QImage to get the pixel value at the mouse position:

    @
    QRgb rgbVal = image.pixel(mouseEvent->x(), mouseEvent->y());
    @

    If I do that on each mousemove event, and it's copying and not sharing memory, I worry about performance.. Perhaps there is a better way for me to get the pixel value at the mouse-location from the QWebView widget itself?

    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