Rajendra Badam
Rajendra Badam

Reputation: 11

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. GUI comes up good in the screen. Application runs in framebuffer mode, X11 is not present in Linux.

I want to know the DPI of the screen in my application.

I used below Qt API to get DPI

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

Output of the above is

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

It is not fetching the required DPI value.

Screen size 800*480.

Same API works good in Ubuntu Linux 18.04 and Windows.

physicalDotsPerInch is not working as expected.

Is there any alternative API that I can use to get DPI of the screen in embedded Linux running in frame buffer mode.

Upvotes: 1

Views: 565

Answers (1)

Eddy Alleman
Eddy Alleman

Reputation: 1096

Is it possible to get QApplication::primaryScreen()->physicalSize? If so you could calculate the DPI yourself by using the geometry of your window.

What device are you using? what is the output of : manufacturer model name

Upvotes: 1

Related Questions