简体   繁体   English

ApplicationWindow不遵守大小

[英]ApplicationWindow doesn't respect size

I'm having an issue understanding the width and the height attributes of the ApplicationWindow setting in a very simple IOS program. 我在了解一个非常简单的IOS程序中ApplicationWindow设置的widthheight属性时遇到问题。 Take for instance the following code: 以下面的代码为例:

import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1

ApplicationWindow {
    title: "Hellow"
    width: 1024
    height: 1920
    visible: true

    Rectangle{
        width: 300
        height: 300
        color: "blue"
    }
}

When I compile using Qt 5.5 my blue Rectangle appears much larger than I would expect. 当我使用Qt 5.5进行编译时,我的蓝色Rectangle看起来比我预期的要大得多。 I've played with the width and height of the Rectangle and it seems like the ApplicationWindow is more on the order of width: 390 , height: 650 regardless of what I have set. 我已经玩过Rectanglewidthheight ,并且无论我设置了什么,似乎ApplicationWindowwidth: 390顺序都是width: 390height: 650

Any thoughts? 有什么想法吗? Thanks 谢谢

The High DPI Displays documentation might be useful here. 高DPI显示”文档在这里可能很有用。 In particular, you could try setting QT_DEVICE_PIXEL_RATIO to 1 before running your application and see if that results in the Rectangle being sized in the way you want it to be. 特别是,您可以在运行应用程序之前尝试将QT_DEVICE_PIXEL_RATIO设置为1然后查看是否会导致Rectangle调整大小。

This link answers my question. 此链接回答了我的问题。

https://forum.qt.io/topic/43513/solved-ios-retina/6 https://forum.qt.io/topic/43513/solved-ios-retina/6

Specifically from there: 特别是从那里:

On iOS the dimension that you get is the logical dimension of the iOS screens. 在iOS上,您获得的尺寸是iOS屏幕的逻辑尺寸。 This happens also if you program natively with Xcode on iOS. 如果您在iOS上使用Xcode进行本地编程,也会发生这种情况。 So, when you create a Rectangle of 320 logical pixel, on non-Retina iOS devices it will use 302 real pixel, but on retina iOS devices it will use the double of pixel (640). 因此,当您创建320逻辑像素的Rectangle时,在非Retina iOS设备上它将使用302实像素,但是在Retina iOS设备上它将使用像素的两倍(640)。

The link also offers some additional advice on how to get screen independent drawing. 该链接还提供有关如何获取屏幕独立图形的一些其他建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM