QT Demo window (4) Screeninfo

Source: Internet
Author: User

After you start the program, you will see one of the following interfaces after skipping splash screen:

Let's focus on the lower half of the interface screen Info section.

Each of the above shows:

    • Screen name
    • Screen size (i.e. resolution)
    • Pixel density
    • Logical pixel Density
    • Available screen sizes
    • Screen orientation
    • The original screen orientation

Let's start with the practical meaning of each item.

Screen name

On a PC, if only one screen is displayed as \\.\display1, and if it is a dual screen, it will be displayed as \\.\display2.

After we get the name of the screen, we can determine which display device is currently displayed on, so we can do some custom actions.

Screen size and available screen size screens do not have a direct interface to get the size of the screen and the size of the screen available, but instead provide the following two sets of properties:
    • Screen.width and Screen.height
    • Screen.desktopavailablewidth and Screen.desktopavailableheight

The values of Screen.width and Screen.height represent the original size of the screen, while Screen.desktopavailablewidth and Screen.desktopavailableheight are removed from the status bar, A system-managed section, such as a management bar.

Therefore, when you are working with a centered control, you need to use SCREEN.XXX if the center is full-screen, and if it is centered within the display area, use SCREEN.DESKTOPAVAILABLEXXX.

Pixel density and logical pixel density

These two parameters are obtained by the pixeldensity and Logicalpixeldensity properties, respectively. However, in the official documentation, the Logicalpixeldensity attribute is marked as obsolete, which is said to be obsolete.

The definition of pixel density, as defined on Wikipedia, is an exponent that represents the number of pixels on a printed image or display unit area. It is generally used to measure the fine degree of computer monitors, televisions and handheld electronic devices. Typically, the higher the pixel value per inch, the finer the image the screen can display.

The definition above is not complicated to read, but the specific pixel density and the logical pixel density represent what I personally do not understand. I first made a test to change the screen resolution and then run the program again to see if the pixel density and the value of the logical pixel density have changed.

The result of the test is that the values for pixel density and logical pixel density are fixed 72PPI and 96PPI, and do not change with the resolution setting. Therefore, we can conclude that pixel density and logical pixel density are the physical properties of a screen.

Screen orientation and the original screen orientation

Screen is represented by the orientation and Primaryorientation properties, respectively, on the current orientation and the original screen orientation, on the PC, this two value is always landscape (2), where 2 is horizontal, if it is landscape ( 8) indicates a 180° rotation of the landscape.

By getting the orientation of the screen and the original orientation, you can better adjust the display of the control on devices that support rotation.

Summarize

This blog is a comparison of water, mainly to understand the QT in the Screen object. In practice, the most we use is screen.width and screen.height.

QT Demo window (4) Screeninfo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.