Skip to content

feat: dual WebKit/WebEngine support for plot layout item#421

Merged
ghtmtt merged 1 commit intoghtmtt:qt6_migrationfrom
bruno-portfolio:layout-dual-support
Mar 31, 2026
Merged

feat: dual WebKit/WebEngine support for plot layout item#421
ghtmtt merged 1 commit intoghtmtt:qt6_migrationfrom
bruno-portfolio:layout-dual-support

Conversation

@bruno-portfolio
Copy link
Copy Markdown
Contributor

@bruno-portfolio bruno-portfolio commented Mar 31, 2026

Continues #420

Adds dual rendering support for PlotLayoutItem to work on both QGIS 3 (QtWebKit) and QGIS 4 (QtWebEngine).

Uses the same Qgis.versionInt() >= 40000 pattern from the rest of the PR.

Changes in plot_layout_item.py

  • Conditional imports: QtWebEngine (QGIS 4) / QtWebKit (QGIS 3)
  • LoggingWebPage: dual class with correct javaScriptConsoleMessage signature for each engine
  • ITEM_TYPE: enum compat (ItemType.PluginItem vs PluginItem)
  • __init__: WebEngine uses offscreen QWebEngineView + Plotly.toImage() pipeline; WebKit uses QWebPage + mainFrame() + palette transparency
  • draw(): WebEngine renders from captured pixmap; WebKit renders directly via mainFrame().render(painter)
  • load_content(): WebEngine loads from temp file; WebKit uses mainFrame().setHtml()
  • loading_html_finished(): WebEngine runs async Plotly.toImage() capture; WebKit marks loaded immediately
  • DPI scaling: WebEngine returns 8, WebKit returns 72

Notes

Ref #377

@ghtmtt
Copy link
Copy Markdown
Owner

ghtmtt commented Mar 31, 2026

great! Merging and testing on my machine!

@ghtmtt ghtmtt merged commit aa68654 into ghtmtt:qt6_migration Mar 31, 2026
0 of 3 checks passed
ghtmtt added a commit that referenced this pull request Mar 31, 2026
* initial commit to port the plugin to QGIS 4 and Qt6

* fix imports

* fix: migrate QtWebKit API to QtWebEngine for Qt6/QGIS 4 compatibility

* fix: wait for Plotly render before grab() in print layout

* fix: use temp file for WebEngine rendering in print layout setHtml() creates an opaque Chromium origin that silently blocks file:// script loading (Plotly.js).

* fix: prevent reload loop during WebEngine async loading in print layout

* fix: use Plotly.react() promise to detect render completion

* fix: use Plotly.toImage() to bypass unreliable WebEngine compositor grab()

* fix: pass explicit viewport dimensions to Plotly.toImage()

* fix: scale captured pixmap to fill layout item rect

* fix: reduce Plotly.toImage scale to 1 (viewport is already 13K+ px)

* fix: reduce widget viewport size and rebalance toImage scale for sharper rendering

* [WIP] plugin compatible for both QGIS3 and QGIS4

* feat: dual WebKit/WebEngine support for plot layout item ref #377 (#421)

* remove variable qgis_version

---------

Co-authored-by: Bruno Escalhão <greengatebrasil@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants