This repository was archived by the owner on Apr 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
examples/quickandroidexample Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,10 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
3232
3333int main (int argc, char *argv[])
3434{
35+ QGuiApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
3536 QGuiApplication app (argc, argv);
3637
38+
3739 QQmlApplicationEngine engine;
3840
3941 /* QuickAndroid Initialization */
Original file line number Diff line number Diff line change 11#include < QObject>
22#include < QtQml>
33#include < QSysInfo>
4+ #include < QGuiApplication>
45#include " qadevice.h"
56#include " qadrawableprovider.h"
67
@@ -87,6 +88,12 @@ static void init() {
8788 m_dp = metrics.getField <float >(" density" );
8889 m_dpi = metrics.getField <int >(" densityDpi" );
8990
91+ QGuiApplication *app = qobject_cast<QGuiApplication*>(QGuiApplication::instance ());
92+ if (app->testAttribute (Qt::AA_EnableHighDpiScaling)) {
93+ m_dp = m_dp / app->devicePixelRatio ();
94+ m_dpi = m_dpi / app->devicePixelRatio ();
95+ }
96+
9097 /* Is Tablet. Experimental code */
9198
9299 QAndroidJniObject configuration = resource.callObjectMethod (" getConfiguration" ," ()Landroid/content/res/Configuration;" );
You can’t perform that action at this time.
0 commit comments