I have one instance of QWebEnginePage that is loaded with some url (e.g. https://www.google.com)
I want this page to be displayed in two QWebEngineViews, but it looks like Qt doesn't allow that.
Once I call setPage on one view, the other view stops rendering the page.
Looks like it is a matter of ownership or something like that, but I don't see any information about that in Qt docs.
Anyone else faced such issue?
auto p = new QWebEnginePage();
auto w1 = new QWebEngineView();
auto w2 = new QWebEngineView();
Like most classes in Qt,
QWebEnginePage is a
QObject always have exactly one parent (owner). The same is true for
QWebEnginePage. Furthermore, it has a method
QWebEnginePage::view returns a pointer to the
QWidget currently showing the page. Therefore, it can by definition only have a single view.
I would suggest creating two
QWebEnginePage instances and connecting the signals to their respective slots (or lambdas which call a corresponding non-slot setter) of the other page. Some like
scrollPositionChanged might not have corresponding setters, so you might be out of luck for perfect synchronization.