nodegui-plugin-webview
nodegui-plugin-webview copied to clipboard
Can't add Webview as Widget to Another Layout
For whatever reason the Webview only seems to work in its own window. Once I try to add the Webview as a widget to the layout of another element, the app no longer launches.
WORKING EXAMPLE (EXAMPLE #1):
import { QWebEngineView, QWebChannel } from "nodegui-plugin-webview";
const webview = new QWebEngineView();
webview.setInlineStyle("align-self:'stretch';");
webview.load("http://google.com");
const channel = new QWebChannel();
webview.page().setWebChannel(channel);
webview.show();
(global as any).wv = webview;
NOT WORKING EXAMPLE (EXAMPLE #2):
import { QWebEngineView, QWebChannel } from "nodegui-plugin-webview";
import {
QMainWindow,
QWidget,
FlexLayout,
QPushButton
} from "@nodegui/nodegui";
const win = new QMainWindow();
const center = new QWidget();
const webview = new QWebEngineView();
webview.setInlineStyle("align-self:'stretch';");
webview.load("http://google.com");
const channel = new QWebChannel();
webview.page().setWebChannel(channel);
const button = new QPushButton();
button.setText("Hello");
center.setLayout(new FlexLayout());
center.layout?.addWidget(webview);
center.layout?.addWidget(button);
win.setCentralWidget(center);
win.show();
(global as any).win = win;
Example #1 works and the app launches, example #2 produces this error:
- webpack 5.49.0 compiled successfully in 3012 ms
- QtWebEngineProcess[14121] <Error>: read failed
- QtWebEngineProcess[14121] <Error>: SeatbeltExecServer: failed to read buffer length.
The app starts to launch, then closes immediately.
No sure what is going on.
Following up on this Issue.
Why can't the Webview be used as a "Child View" like any other widget?
Even the example/demo (Demo.ts) breaks and shows an error if you try and use the Webview as a child/widget.
It works only if you allow the widget to open in a new window.