Android Studio的Qt工具

Qt Tools for Android Studio

Android Studio的Qt工具

May 27, 2024 by Nikunj Arora | Comments

​2024年5月27日:Nikunj Arora |评论

The Qt Tools for Android Studio plugin allows you to create new or import existing Qt QML projects to an Android Studio project. Therefore, you can embed QML elements, such as a 3D view, inside your Android project without installing or using Qt Creator. The plugin requires Qt 6.7 or later. Please have a look here for all the prerequisites needed. 

​Android Studio的Qt Tools插件允许创建新的或将现有的Qt QML项目导入Android Studio项目。因此,可以在Android项目中嵌入QML元素,如3D视图,而无需安装或使用Qt Creator。该插件需要Qt 6.7或更高版本。请在这里查看所需的所有先决条件。 

To install the plugin, go to the JetBrains marketplace page and install it directly or download the plugin jar file. See the docs for instructions on installing the plugin with the jar file.  

​要安装插件,请转到JetBrains市场页面,直接安装或下载插件jar文件。有关使用jar文件安装插件的说明,请参阅文档。  

The plugin needs to know where certain parts of the Qt toolchain are. Go to File -> Settings, expand the Build, Execution, Deployment section, and select Qt. If you didn't change the location of the Qt installation during installation, it should be automatically filled in; otherwise, please provide the location manually.  

插件需要知道Qt工具链的某些部分在哪里。转到文件->设置,展开构建、执行、部署部分,然后选择Qt。如果在安装过程中没有更改Qt安装的位置,则应自动填写;否则,请手动提供位置。

In the first field, you need to provide the path to qt-cmake. You can find this file in [Qt Folder Path]/<qt version>/android_<architecture>/bin. For example, C:\Qt\6.7.0\android_arm64_v8a\bin\qt-cmake.bat (Note that you need to select qt-cmake.bat for Windows and qt-cmake for Linux and Mac).  

在第一个字段中,需要提供qt-cmake的路径。可以在[Qt文件夹路径]/<Qt-version>/android_<architecture>/bin中找到此文件。例如,C:\Qt\6.7.0\android_arm64_v8a\bin\qt-cmake.bat(注意,需要为Windows选择qt-cmake.bat,为Linux和Mac选择qt-cmake)。

We will import the QML in Java-Based Android Projects simple example project.  

​我们将在基于Java的Android项目的简单示例项目中导入QML。  

In Android Studio, go to File -> Open, or select Open from the Android Studio welcome screen. Navigate to the example project, select the “qml_in_java_based_android_project” folder, and press OK. 

在Android Studio中,转到文件->打开,或从Android Studio欢迎屏幕中选择打开。导航到示例项目,选择“qml_in_java_based_android_project”文件夹,然后按OK。

Once the project opens, go to File -> New -> Import Qt Project... and select the “qml_in_android_view” folder from the example project. 

项目打开后,转到文件->新建->导入Qt项目……并从示例项目中选择“qml_in_android_view”文件夹。

After importing, if your configuration has a problem, an error popup will appear, as shown. 

导入后,如果您的配置有问题,将显示一个错误弹出窗口,如图所示。

Click on the “Configure” button to open the Qt settings page.  

单击“配置”按钮打开Qt设置页面。

Now, you can see your project directory structure in the project view on the left.  

现在,可以在左侧的项目视图中看到项目目录结构。

 

Pressing the Run button will build the Qt project, copy all the dependencies, and modify the build.gradle file, and run the Android app on the emulator or a physical device, depending on which you are using. 

按下Run按钮将构建Qt项目,复制所有依赖项,修改build.gradle文件,并在模拟器或物理设备上运行Android应用程序,具体取决于使用的设备。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值