Size of ApplicationWindow
-
Hi,
I'm making an ApplicationWindow, I set the width and the height respectively to maximumWidth and maximumHeight but when I set for example minimumWidth and minimumHeight to maximumWidth - 200 and maximumHeight - 200, the application crash so do you have any clue why when there are those Macro for this value it's crash ?
Thanks in advance for your answer !
-
sample code please ?
-
@dheerendra ApplicationWindow {
id: mainWindow
visible: true
width: maximumWidth
height: maximumHeight
minimumWidth: 1500
minimumHeight: 1000
} -
Can you try creating new QML UI application and set some width/height like this see ? E.g I tried something like on the mac. I did not see any problem. Since you are facing the problem you can some new program like the follows. It may be crashing for something else.
ApplicationWindow {
visible: true
width: 640
height: 480
minimumHeight: 800
minimumWidth: 800
title: qsTr("Hello World")}
Which platform you are trying ?
-
@dheerendra The problem I guess it's not the platform but i'm on CentOs 7, and the code that I send above work it doesn't work when I do :
ApplicationWindow {
id: mainWindow
visible: true
width: maximumWidth
height: maximumHeight
minimumWidth: maximumWidth - 200
minimumHeight: maximumHeight - 200
}The value 200 is just an example whatever the value is, it doesn't work so the question was why maximum Width and Height can't be use in minimum Width and Height ?
-
what is the value assigned for maximumWidth and maximumHeight ? U need to explicitly assign the value for it. Try assigning the
maximumWidth = 1000;
maximumHeight = 1000;After this it should work. Once U confirm I will tell you why it crashes.
-
@dheerendra I don't know the value depends on the size of your screen (those value aren't value that I have created but they are macro, I guess, that have the size of your screen)
-
Can you confirm what is the values of maximumWidth and maximumHeight ? Just print them & check ? Which macro is calculating these values ? Are you assigning Screen.Width and Screen.Height to maximumWidth and maximumHeight ?
ApplicationWindow {
id : top
visible: true
// width: maximumWidth
// height: maximumHeight
width: 300
height: 400
minimumHeight: maximumHeight-200
minimumWidth: maximumWidth-200
title: qsTr("Hello World")MouseArea { anchors.fill: parent onClicked: { console.log(top.maximumWidth) console.log(top.maximumHeight) } }
}
-
@dheerendra The value is 16777215 for both so I guess it's not the right macro to know the size of a screen. So do you know what is the right one ?
-
So this value is causing the issue. No macro decides this size. You need to set the max size which you prefer. Becz of this huge value, it is crashing. Set the max size appropriately based on the Screen Size. Everything should work fine.
-
@dheerendra I solved the problem, the macro that have the size of the actual screen is Screen.width and Screen.height with the import Qt.Quick.Window 2.0.
Thanks for your help !
-
Cool. Yes, Screen.Width and Screen.Height are the right properties to get the screen size.