简体   繁体   English

如何在 Linux 帧缓冲模式下通过 Qt 应用程序获取屏幕 DPI(无 X11)

[英]How to get Screens DPI by Qt application in Linux framebuffer mode(without X11)

Currently I am running Qt and QML application in Embedded Linux Built using buildroot.目前我正在使用 buildroot 构建的嵌入式 Linux 中运行 Qt 和 QML 应用程序。 GUI comes up good in the screen. GUI 在屏幕上显示良好。 Application runs in framebuffer mode, X11 is not present in Linux.应用程序以帧缓冲模式运行,Linux 中不存在 X11。

I want to know the DPI of the screen in my application.我想知道应用程序中屏幕的 DPI。

I used below Qt API to get DPI我使用下面的 Qt API 来获取 DPI

qreal screenDPI = QApplication::primaryScreen()->physicalDotsPerInch();
qDebug() << "***************screenDPI***************" << screenDPI;

Output of the above is上面的输出是

***************screenDPI***************inf

It is not fetching the required DPI value.它没有获取所需的 DPI 值。

Screen size 800*480.屏幕尺寸 800*480。

Same API works good in Ubuntu Linux 18.04 and Windows.相同的 API 在 Ubuntu Linux 18.04 和 Windows 中运行良好。

physicalDotsPerInch is not working as expected. physicalDotsPerInch未按预期工作。

Is there any alternative API that I can use to get DPI of the screen in embedded Linux running in frame buffer mode .是否有任何替代 API 可用于在以帧缓冲模式运行的嵌入式 Linux 中获取屏幕的 DPI。

Is it possible to get QApplication::primaryScreen()->physicalSize?是否有可能获得 QApplication::primaryScreen()->physicalSize? If so you could calculate the DPI yourself by using the geometry of your window.如果是这样,您可以使用窗口的几何形状自己计算 DPI。

What device are you using?你在使用什么设备? what is the output of : manufacturer model name输出是什么:制造商型号名称

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

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