Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QFontMetrics does not account for windows dpi scaling
Milo last edited by Milo
when changing dpi scaling from 100% to 200% in Windows 10, i expect the following string to be twice as wide.
QFont font = QFont("arial", 10); QFontMetrics fm(font); int width = fm.width("abcdefgABCDEFG");
Strangely there is only 1 pixel difference.
100% --> width = 108 pixels
200% --> width = 109 pixels
Why is that? Do I need to compute the scaled size of the text myself?
I did enable automatic high DPI scaling in my QApplication.
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication* app = new QApplication(temp, NULL);