Changing DPI scaling size of display make Qt application’s font size get rendered bigger

High DPI support is enabled from Qt 5.6 onward. Setting QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling) in your application source code allows automatic high-DPI scaling. NOTICE: To use the attribute method, you must set the attribute before you create your QApplication object: #include <QApplication> int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); return app.exec(); }

Capturing a time in milliseconds

To have millisecond precision you have to use system calls specific to your OS. In Linux you can use #include <sys/time.h> timeval tv; gettimeofday(&tv, 0); // then convert struct tv to your needed ms precision timeval has microsecond precision. In Windows you can use: #include <Windows.h> SYSTEMTIME st; GetSystemTime(&st); // then convert st to your … Read more

How to calculate dp from pixels in android programmatically [duplicate]

All the answers here show a dp->px conversion rather than px->dp, which is what the OP asked for. Note that TypedValue.applyDimension cannot be used to convert px->dp, for that you must use the method described here: https://stackoverflow.com/a/17880012/504611 (quoted below for convenience). fun Context.dpToPx(dp: Int): Int { return (dp * resources.displayMetrics.density).toInt() } fun Context.pxToDp(px: Int): Int … Read more

How to detect the current screen resolution?

Size of the primary monitor: GetSystemMetrics SM_CXSCREEN / SM_CYSCREEN (GetDeviceCaps can also be used) Size of all monitors (combined): GetSystemMetrics SM_CX/YVIRTUALSCREEN Size of work area (screen excluding taskbar and other docked bars) on primary monitor: SystemParametersInfo SPI_GETWORKAREA Size of a specific monitor (work area and “screen”): GetMonitorInfo Edit: It is important to remember that a … Read more

tech