Qt的code在Android移植以及它是如何工作的 [英] Porting of Qt code on Android and how it works

查看:234
本文介绍了Qt的code在Android移植以及它是如何工作的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android上移植我的Qt应用程序。

I was thinking of porting my Qt application on android.

我的问题是如何在code写在C ++和Qt这也是一个C ++库被移植到Android的安卓需要Java code,并在设备上安装应用程序的apk文件是必要的。我很好奇他们是什么和如何做的东西在code,使其工作就像一个java code。

My question is how a code written in C++ and Qt which is also a C++ library gets ported to android as android requires java code and an apk file is needed to install the app on device. I am curious as to how and what things they do on the code to make it work like a java code.

如果这个问题不明确,请评论,我会尽我所能,使之更加清晰。

If the question is not clear , please comment and i will do my best to make it more clear.

推荐答案

Android应用程序是Java应用程序,名为Dalvik的在虚拟机上运行。这导致许多挑战一个Qt / C ++应用程序在这样一个基于Java的平台上运行。要ovecome这一点,一个Qt为Android应用程序有两部分。第一部分是你的Qt / C ++其通过的qmake组织机应用程序。第二部分是一个发射器是Qt Creator所产生的Java code自动根据您的应用程序preferences,设置和目标Android版本。

Android applications are Java applications, running on a virtual machine called "Dalvik". This causes many challenges for a Qt/C++ application to run on such a Java based platform. To ovecome this, a Qt for Android application has two parts. The first part is your Qt/C++ native application which is organized by qmake. The second part is a launcher which is a Java code generated by Qt Creator automatically based on your application preferences, settings and target Android version.

该发射器是一个Java进程,使Qt的Andr​​oid应用程序有一个基于Java的切入点。 Java的code。在发射器将加载所需的Qt库的基础上,在其他文件中给出的模板中的元信息。所以,当一个Qt的Andr​​oid应用程序启动时,它只是一个普通的Java应用程序。入口点会在 QtActivity.java 可以在安卓/ src目录/ ... 在你的项目构建目录中找到

The launcher is a Java process, so Qt Android applications have a Java-based entry point. The Java code in launcher will load the required Qt libraries, based on the meta-information given in other files in the template. So when a Qt for Android application is started, it's just a regular Java application. The entry point will be in QtActivity.java which can be found under android/src/… in your project build directory.

加载Qt库后,Java code将启动应用程序的本地main()函数在一个新的线程和应用程序将启动。在这一点上,爪哇code,以便从机器人事件委派到Qt。 Qt的Andr​​oid应用程序使用Java本地接口(JNI),Java世界和C ++世界之间的通信。

After loading the Qt libraries, the Java code will start the application's native main() function on a new thread and the application will launch. At this point, the Java code is used to delegate events from Android into Qt. Qt for Android applications use "Java Native Interface" (JNI) to communicate between Java world and C++ world.

这篇关于Qt的code在Android移植以及它是如何工作的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆