Important: Please read the Qt Code of Conduct -

[Solved]WebView has Weird question on Qt 5 (size problem)

  • My code was as simple as those:
    @ WebView {
    id: testWebViewJs
    anchors.fill: parent
    url: "http://localhost"
    onUrlChanged: {

    My environment is Qt 5.2 with mingw on WIndows 7.
    I'm working on a qml based tool which is using QtQuick 2.2.
    Here is the problem:
    1.first of all,I can not drag a WebView to ui in the design mode ,it tells me :
    "Using Qt Quick 1 code mode instead of Qt Quick 2 (M324)"
    Even I add WebView manually in code mode,it still show me these error,I had to use "// @disable-check M324" to avoid this message.

    2.The WebView shows correct html at the beginning,then I found that it will take over other widgets's place when I scroll up/down the webpage,it seems like the WebView was squatting places outisde of the Rectangle wrapper,suddenly i realized maybe it's just the size probelm.
    Then I found preferredHeight and preferredWidth in the design mode,but it tells me "Cannot assign to non-existent property "preferredHeight".
    I checked Qt 5.2's doc,it's just a few Properties and doesn't have preferredWidth/preferredHeight
    I can't move anymore,should I use Qt Quick 1 instead(I rather not to)?is that a wrong tool for display html content?Grateful for any advice.

  • it turns out it's all because of my dropshadow code like this:
    DropShadow {
    id: rectShadow;
    anchors.fill: source
    cached: true;

        verticalOffset: 0;
        radius: 8.0;
        samples: 16;
        color: "#80000000";
        smooth: true;
        source: container;


    I have drawn a shadow around the container(window),webview was in within the window of course,so I still don't know why it's happened,but I can resolve it by simply comment these codes,it works fine now.
    Thanks to my rubber duck

Log in to reply