我在获得默认屏幕方向方面有问题。
我没有找到从Qt代码中获取这个方向的任何方法,但是我发现android.provider.Settings.System.USER_ROTATION包含了我需要的信息。除了运行Java代码之外,我如何从Qt获得这个属性?
http://community.kde.org/Necessitas/JNI,也许我可以将这个属性的值从主java类放到我的Qt代码中?(我指的是QtActivity.java)
user_rotation 0 -> ROTATION_0
user_rotation 1 -> ROTATION_90
user_rotation 2 -> ROTATION_180
user_rotation 3 -> ROTATION_270 谢谢你的帮助
upd:我在QtActivity.java中找到了有趣的行
loaderParams.putString(APPLICATION_PARAMETERS_KEY, parameters.replace(' ', '\t'));也许我可以加载默认的屏幕方向作为参数?
我会的
发布于 2014-07-02 21:57:19
不需要java
QScreen *s = app.primaryScreen();
qDebug() << "nativeOrientation: " << s->nativeOrientation();
qDebug() << "orientation: " << s->orientation();
qDebug() << (s->isLandscape(s->nativeOrientation()) ? "nativeOrientation lanscape" : "nativeOrientation not lanscape");
qDebug() << (s->isLandscape(s->orientation()) ? "orientation lanscape" : "orientation not lanscape");
qDebug() << (s->isPortrait(s->nativeOrientation()) ? "nativeOrientation portrait" : "nativeOrientation not portrait");
qDebug() << (s->isPortrait(s->orientation()) ? "orientation portrait" : "orientation not portrait");https://stackoverflow.com/questions/24530228
复制相似问题