Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Does using QPainter to "copy" a canvas embedded in QWebView copy or share memory?
pmh4514 last edited by
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?