Search code examples
c++qtsizepixeldiagonal

Get screen diagonal size in Qt


Is there any way to get size of diagonal of the screen (in inches) in Qt? I need it to calculate how big is my pixel. Or maybe I can get pixel size directly?


Solution

  • In order to get screen size, you can use QScreen::physicalSize.

    Also, you can get the number of pixels per inch, by using QScreen::physicalDotsPerInch

    QScreen *screen = qApp->screens().at(0);
    qDebug() << screen->geometry() << screen->physicalSize() << screen->physicalDotsPerInch();