Skip to main content

Qt Weekly #24: High-dpi QtWayland



Those of you following QtWayland development closely might have seen commit 7ef5e2e4 – Implement high-dpi support. In this blog we’ll look at some examples and show how to test the support on high and normal dpi hardware.


Wayland


Wayland 1.2 added support for high-dpi scaling via



  • wl_output::scale

  • wl_surface::set_buffer_scale


wl_output::scale is used by the compositor to inform the client that it will scale buffers by the given scale factor (presumably because it is compositing to a high resolution display). The client then has the option of providing high resolution buffers and bypass the compositor scaling. This is done by calling set_buffer_scale (and then actually creating larger buffers). Typical values for the scale factor is 1 and 2; Wayland supports integer factors only. From he client point of view the buffer sizes are the only thing that changes with the scale factor, other wl_surface geometry is not multiplied by it.


Qt


Creating larger buffers and rendering high-dpi content is handled internally by Qt using the existing devicePixelRatio implementation. This implementation is also in use on OS X and iOS, and – via the QT_DEVICE_PIXEL_RATIO environment variable in Qt 5.4 – in experimental form on X11 and Windows. The details of this mode have been covered elsewhere; the main thing to be aware of as an app developer is that you need to provide high-resolution raster artwork, and that raw OpenGL are in device pixels and see the full display resolution.


Weston


Recent versions of the Weston compositor (I’m using 1.6.0) supports running in scaled mode:



./bin/weston --width=640 --height=480 --scale=2

We can then launch any Qt app, as usual:



./anyqtapp -platform wayland

high-dpi and normal-dpi rendered Flat style demo

high-dpi and normal-dpi rendered Flat style demo – best viewed at full size



The screenshots illustrate the benefits of the devicePixelRatio scaling mode: The application is automatically rendered at a higher resolution; no modifications to app code is needed. In cases where high-resolution content is not available there is a graceful degradation to low-resolution content, without breaking layouts or by displaying “small” user interface elements.


High-dpi support is currently implemented in the “dev” branch of QtWayland and are on track to be released with Qt 5.5.






Source :- Qt Blog http://ift.tt/1H5jg7f

Comments

Popular posts from this blog

Integrating custom OpenGL rendering with Qt Quick via QQuickFramebufferObject

Integrating custom OpenGL rendering code, for example to show 3D models, with Qt Quick is a popular topic with Qt users. With the release of Qt 5.0 the standard approach was to use the beforeRendering and afterRendering signals to issue the custom OpenGL commands before or after the rendering of the rest of the scene, thus providing an over- or underlay type of setup. With Qt 5.2 a new, additional approach has been introduced: QQuickFramebufferObject . This allows placing and transforming the custom OpenGL rendering like any other Quick item, providing the most flexible solution at the expense of rendering via OpenGL framebuffer objects. While it was little known at the time of its original release, it is becoming more and more popular in applications built with Qt 5.4 and 5.5. It is also one of the building blocks for Qt 3D, where the Scene3D element is in fact nothing but a QQuickFramebufferObject under the hood. We will now take a look at this powerful class, look at some example...

Qt Weekly #27: WiFi networking support on embedded devices

As a part of the Qt for Device Creation offering we provide several helpful add-on modules that assist in creating applications for embedded devices. In this blog post I would like to demonstrate some of the features supported by the B2Qt WiFi add-on module. What is it? The B2Qt WiFi module provides APIs for connecting embedded devices to a wireless network. There are C++ and QML APIs available for managing wireless network connectivity, scanning for wireless network access points, retrieving information from these access points, monitoring for network state changes and more. The API allows you to manage when and to which network to connect, and when to go offline. Overview of the API The module consists of 3 classes: (Q)WifiConfiguration – Used to define a network configuration. (Q)WifiDevice – Represents a physical device. (Q)WifiManager – Main interface to the WiFi functionality (Singleton). How to use it Here is a code snippet in QML demonstrating how easy it is to connect a ...

High-DPI Support in Qt 5.6

Qt 5.6 brings improved high-DPI support, in the form of better support for the devicePixelRatio scaling mode. In this blog we’ll look at how to configure and enable it, from the perspective of a Qt application user and a Qt application developer. Unscaled sammegame vs scaled samegame Developing applications won’t be covered in depth now, but has to some extent been covered earlier . The short story is that applications generally benefit from this high-DPI mode even without modifications. This high-DPI mode is a virtualization mode, where there is not necessarily a 1:1 correspondence between a unit in the QWidget/Quick item coordinate system and a pixel on screen. One “unit” then has constant visual size across systems with different display densities, and actual screen pixel density is to a large degree hidden from the application. Dots Per Inch (DPI) is the traditional measurement for display density, where a standard density display has a DPI value of 72 or 96. Qt as always...