C# Method Resolution, long vs int

The int version of bar is being called, because 10 is an int literal and the compiler will look for the method which closest matches the input variable(s). To call the long version, you’ll need to specify a long literal like so: foo.bar(10L); Here is a post by Eric Lippert on much more complicated versions …

Read more

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(); }

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

Is there a way to determine android physical screen height in cm or inches?

Use the following: DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); double x = Math.pow(mWidthPixels/dm.xdpi,2); double y = Math.pow(mHeightPixels/dm.ydpi,2); double screenInches = Math.sqrt(x+y); Log.d(“debug”,”Screen inches : ” + screenInches); When mWidthPixels and mHeightPixels are taken from below code private void setRealDeviceSizeInPixels() { WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); DisplayMetrics displayMetrics = new DisplayMetrics(); display.getMetrics(displayMetrics); // …

Read more