QML中的Retina支持 [英] Retina support in QML

查看:70
本文介绍了QML中的Retina支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 QML 中使用视网膜支持?如何选择正确的尺寸和正确的图像分辨率?应用需要在视网膜和非视网膜设备上运行.

How to use retina support in QML? How to choose correct sizes and correct resolution of images? App needs to work on retina and not-retina devices.

推荐答案

可以找到在支持 hdpi 方面,Qt Quick 2 和 Qt Quick Controls 开箱即用.需要考虑的重要事项是栅格内容,如文章所述:

Qt Quick 2 and the Qt Quick Controls work well out-of-the box when it comes to hdpi support. An important thing to take into consideration is raster content and as explained in the article:

作为应用程序开发人员,您有两种选择:(忽略不做任何事情"选项)

As an app developer you have two options: (ignoring the "do-nothing" option)

Replace existing raster content with a high-resolution version
Provide separate high-resolution content

第一个选项很方便,因为每个选项只有一个版本资源.但是,您可能会发现(或设计师会告诉您)当为特定分辨率创建图标之类的资源时,它们看起来最好.为方便起见,Qt采用了"@ 2x"图像约定文件名:

The first option is convenient since there is only one version of each resource. However, you may find (or your designer will tell you) that resources like icons look best when created for a specific resolution. To facilitate this, Qt as adopted the "@2x" convention for image filenames:

foo.png foo@2x.png

foo.png foo@2x.png

高分辨率内容可以与原件.必要时将自动加载"@ 2x"版本通过QML Image元素和QIcon:

High-resolution content can be provided side-by-side with the originals. The "@2x" version will be loaded automatically when needed by the QML Image element and QIcon:

图片{source ="foo.png"} QIcon图标("foo.png")

Image { source = "foo.png" } QIcon icon("foo.png")

(请记住要为QIcon设置AA_UseHighDpiPixmaps)

(remember to set AA_UseHighDpiPixmaps for QIcon)


关于主题的另一个主题此处.

这篇关于QML中的Retina支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆