import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Window 2.1 /* Important Note! The described behavior is for MS Windows 8.1 Pro! I cannot speak for any other OS or different Windows version. In this file, a fixed-size(!) pixelWindow is displayed when a resolution is selected from the Resolution menu. The very first time this window displays, it is too small to fit the defined rectangle. (Note the missing top and right borders!) If I change the resolution to something different, the window finally resizes correctly. (Note: just turning the window Off and on again is not enough! The x- or yResolution must change - see semi-workaround in code below) After resizing once, the window always resizes correctly. Only the very first rendering is affected by this problem! I am assuming that I have forgotten some important initialization step, or rendering dependency but I have not been able to find this yet, so I am submitting it as a bug, possibly due to MS Windows 8.1. I have tried several variations, which are commented out below and can be commented back in for testing. */ ApplicationWindow { title: qsTr("Hello World") width: 640 height: 480 ExclusiveGroup { id: resolutionGroup } property int xResolution: 0 property int yResolution: 0 property bool visibleResolutionWindow: false function changeResolution( x, y ) { xResolution = x yResolution = y visibleResolutionWindow = true } function hideResolutionWindow() { /* semi-workaround: activating the next two code lines lets you turn the window Off and then on again in order to fix the incorrect window size. The kluge forces Off to change x/yResolution (which it normally doesn't care about). */ // xResolution = 0 // yResolution = 0 visibleResolutionWindow = false } onClosing: { pixelWindow.close() } Window { id: pixelWindow title: qsTr("Pixels: %1x%2").arg(xResolution).arg(yResolution) width: resRect.width height: resRect.height visibility: visibleResolutionWindow ? "Windowed" : "Hidden" visible: visibleResolutionWindow /* None of the following options work correctly when first opened! The difficulty appears to be with the implementation of MSWindowsFixedSizeDialogHint (or equivalent behavior in SubWindow). Note that I am using MS Windows 8.1 Pro! */ //flags : "Dialog" | "MSWindowsFixedSizeDialogHint" flags : "Tool" | "MSWindowsFixedSizeDialogHint" // flags : "SubWindow" // flags : "Tool" Rectangle { id: resRect width: xResolution + border.width * 2 height: yResolution + border.width * 2 color: "linen" border.width: 5 border.color: "darkgray" } } menuBar: MenuBar { menus: [ Menu { title: qsTr("File") MenuItem { text: qsTr("Exit") onTriggered: Qt.quit(); } }, Menu { title: qsTr("Resolution") MenuItem { text: qsTr("Off") checkable: true checked: true exclusiveGroup: resolutionGroup onTriggered: { hideResolutionWindow() } } MenuItem { text: qsTr("320x240") checkable: true exclusiveGroup: resolutionGroup onTriggered: { changeResolution( 320, 240 ) } } MenuItem { text: qsTr("480x272") checkable: true exclusiveGroup: resolutionGroup onTriggered: { changeResolution( 480, 272 ) } } } ] } Button { text: qsTr("Hello World") anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter } }