QIcon的功能
- QIcon可以用来管理多个QPixmap,可以返回不同状态、大小的QPixmap。
- QIcon支持SVG格式
- 使用QPixmap QIcon::pixmap(const QSize &size, QIcon::Mode mode = Normal, QIcon::State state = Off) const
返回的QPixmap会根据实际大小去决定,不会超过实际大小。但是可以比实际大小小。
Setting the Qt::AA_UseHighDpiPixmaps application attribute enables this function to return pixmaps that are larger than the requested size. Such images will have a devicePixelRatio larger than 1.
devicePixelRatio说明
- 物理像素
设备像素,在同一个设备上,它的物理像素是固定的,这是厂商在出厂时就设置好了的,即一个设备的分辨率是固定的。 - 逻辑像素
- 像素比 即 devicePixelRatio
物理像素与逻辑像素之间的比例。当像素比为1:1时,使用1个物理像素显示1个逻辑像素;当像素比为2:1时,使用4个物理像素显示1个逻辑像素。 - QPainters that are opened on the pixmap will be scaled. For example, painting on a 200x200 image if with a ratio of 2.0 will result in effective (device-independent) painting bounds of 100x100.