Unsolved Crash when trying to bind Window.height to WebEngineView.contentsSize.height (short code)
-
Hi,
I use Qt 5.10.1 on up-to-date Windows 10 and the following simple program does not show any window:
import QtQuick 2.10 import QtQuick.Window 2.10 import QtWebEngine 1.5 Window { id: w visible: true title: "Test" // with this line, the program crashes before showing anything: height: v.contentsSize.height WebEngineView { id: v anchors.left: w.left anchors.right: w.right anchors.top: w.top onContentsSizeChanged: { console.log(contentsSize) // no output if not both width and height properties of the web view are specified w.height = contentsSize.height } // if any of the following 2 lines are omitted, the web view the ":-)" string in the web view does not show up and the window looks empty although anchors.left and anchors.right are set above and the height is set // width: 100 // height: 100 // The following line crashes the program before showing the window // height: v.contentsSize.height Component.onCompleted: { loadHtml(":-)"); } } }
I specifically want the window to be as high as the web view when its size is not constrained. Relevant documentation link: http://doc.qt.io/qt-5/qml-qtwebengine-webengineview.html#contentsSize-prop.
Thanks!
-
@alwayslearning
This seems to be related with a bug when accessingcontentsSize
too early:
https://bugreports.qt.io/browse/QTBUG-65942Apparently, this still doesn't work correctly in Qt 5.10.0, although the bug was considered solved?
As a check, I tried accessing the property in the
onLoadProgressChanged
handler:onLoadProgressChanged: { if (loadProgress===100) console.debug(contentsSize.height) }
This works (I tried by setting the
url
property to a webpage). Maybe as a workaround, you could set your window height in that handler. -
Hi,
The bug report states that 5.10.0 is also affected. It's been solved for 5.9.5 so it will likely be also for the release of 5.11.