QQuickView with frameless window hint - fails if QQuickView::setSource is called



  • I have a Qt Qml application based in a QQuickView window. It works great on OSX/Linux/Windows.

    On Windows 10 (but I've not tried on other operating systems yet), if I add a frameless window hint to the QQuickView window's flag, I get exactly the window I desired (as expected.)

    If I do the same thing and then call setSource( "myqml.qml" ) on that QQuickView, the window will fail to display although the taskbar will show that the application window (the QQuickView.) Note that the setSource call happens after the ::show() call (I tried hiding it, then calling setSource, then unhiding in case there was some window reconstruction issue - but no luck.)

    When this happens, the console output shows: "QSGThreadedRenderLoop: expose event received for window QQuickView(0xc6eb8fef68) with invalid geometry: QRect(-1357,226 0x0) on QScreen(0x277c048c960, name=\.\DISPLAY3)"

    This is the same display that shows successfully if I don't call setSource.

    If the QML file is completely empty or only contains import statements - the window shows properly.
    If I add just the following:

    Rectangle {
    color: "red"
    }

    The window fails to show.

    Interestingly if I give the rectangle a specific size like this:

    Rectangle {
    width: 100
    height: 100
    color: "red"
    border.color: "black"
    border.width: 5
    radius: 10
    }

    Then I do not get the window without a title bar, I get a window exactly the size of the rect and because I gave the corners a radius, I see a white background where the corners would normally be (indicating to me that the window size has shrunk to the size of the rect.)

    Anybody know how to fix this?

    I would expect the same behavior as when there is a titlebar... Is that wrong?

    Thanks!



  • Ahhh, I think that because the base rect in my qml code doesn't define a size (which gives it parent fill properties) and the frameless window doesn't have a parent (which was presumably previously the window frame itself.)

    Strange because I tried defining a minimum size for the QQuickView and then loading the qml and that didn't work.

    Anyhow, not sure if this is a bug or expected behavior (by the implementors) - I suspect the latter.

    I can easily work around by giving the qml base rect a size.



  • I think(but i might be wrong) that it's true with regards to almost all QML visual items - by default, their size is 0x0. With an exception of Image which gets its default size from the picture it shows, and perhaps some others?. Anyway, that's what makes defining proper height/width and/or anchors of all visible Items mandatory.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.