Qml多解析度螢幕適配
property int defaultW : 520
property int defaultH : 900
width: Qt.platform.os == "windows" || Qt.platform.os == "osx" ? defaultW : Screen.desktopAvailableWidth
height: Qt.platform.os == "windows" || Qt.platform.os == "osx" ? defaultH : Screen.desktopAvailableHeight
/*************************************************************************************
計算寬高比例
*************************************************************************************/
function dpW( value )
{
var temp
if(Qt.platform.os == "windows" || Qt.platform.os == "osx" )
{
temp = (mainwindow.width / defaultW) * value
}else
{
temp = Screen.primaryOrientation === 1 ? (mainwindow.width / defaultW) * value : (mainwindow.height / defaultW) * value
}
return temp
}
function dpH( value )
{
var temp
if(Qt.platform.os == "windows" || Qt.platform.os == "osx")
{
temp = (mainwindow.height / defaultH) * value
}else
{
temp = Screen.primaryOrientation === 1 ? (mainwindow.height / defaultH) * value : (mainwindow.width / defaultH) * value
}
return temp
}