Qt on ANDROID:QT Quick's Hello World text

Source: Internet
Author: User
Tags version control system

In the previous article, "Qt on Android:qml Language Foundation", we introduced the grammar of the QML language, in the end we left a few questions did not unfold, this, we formally began to write the Qt Quick program, and those problems, along with this series of articles will be eliminated.

Before we begin to introduce the basic elements of the Qt Quick application, let's start by creating a Helloqtquickapp project, the classic Hello world.

The author's tutorial will eventually target Qt Quick and C + + mixed programming, so we

Helloqtquickapp

Start from scratch.

Create a project

To open Qt Creator, click on the "Pieces (F)" menu and select "New file or item (N)" In the list of pop-up menus. As shown in the following:


After the above operation, Qt Creator will pop up the new project interface and let us choose the application template. As shown in the following:


Here we select the "Application" project, "Qt Quick Application" template. You can see the real-time prompt on the far right, saying that this template supports QML and C + + mixed programming, which is exactly what we need, because the author finally provides a useful example of mixing QML and C + +, and my point is this: complex applications, using QML to quickly build the interface, using C + + to complete the key calculation Law and logic. Also see support for Destop and Android two platforms.
Click "Select (C) ..." button, the New Project Wizard will guide us to the next step, "project description and location." Reference:


Please refer to setting the project name to Helloqtquickapp.

Click "Next" button, follow the wizard to enter the component selection link,


Please refer to the illustration to select Qt Quick 2.0.

Click on the "Next" button and follow the wizard to the build Kit selection ("Kit Selection") link.
I have selected two packages, "Android for armeabi-v7a (GCC 4.7, Qt 5.2.0)" and "Desktop qt 5.2.0 MinGW 32bit". Please check your configuration against the control.


Click on the "Next" button and follow the wizard to the "Project Management" link. Here you can choose whether to add the project to the version control system (such as SVN) and see the files that will be added to our "Helloqtquickapp" project. As shown in the following:


Finally see the "Finish (F)" button and quickly click on it! You will see the following project editing interface (I expanded the project view to see all the files in the project):


Although it is a simple Hello world, the wizard is very enthusiastic to add a lot of files, such as Qtquick2applicationviewer.h/qtquick2applicationviewer.cpp/main.cpp/ Main.qml. Next we make a little change.

Run the project

Replace "Hello World" in the main.qml file with "Hello Qt Quick App" and run the project directly (on your computer) to see the following effect:



Well, our Helloqtquickapp project is done.

Run on the phone

Next let's make some changes so that Helloqtquickapp can run on Android phones.

See:


First we need to click the label labeled 1 to enter the project properties configuration interface, and then click the Labeled 2 button, switch to the Android run option, the third step, the details of the Label 3 button click, expand Deployment Details; Then, reference designator 4, select the QT deployment strategy for use Ministro Service to install Qt; The last step is the button labeled 5, create the Androidmanifest.xml file required by the Android app, and click to see the following interface:


Click the "Complete (F)" button directly. Then I entered the Androidmanifest.xml editing interface:


You can follow the diagram, modify the app's package name, the author changes to An.qt.helloQtQuickApp, and then close the Androidmanifest edit interface will prompt you to save, choose to save all on the line.

The new Project view is as follows:



Notice the area I marked.

Now our project has finally been perfected and can be run on Android Sh. If the QT on Android project settings are unclear, please step to my other article-"Qt on Android: Graphic detailed Hello World", if you have not set up the QT on Android development environment, please refer to "under the Windows QT 5.2 F or Android Development primer.

Run the project, will let you choose the target device, I connect the real machine, select the real machine. For details, please refer to the Qt on Android: text-to-detail Hello world process. Here's how it works:


Doesn't look attractive to you? Yes, that's true. But, this is just the beginning, just beginning. With in-depth learning, you can make your own beautiful apps and cool games. If you can't wait, try out some of the QT Quick's sample programs in the QT SDK to run and see.

Alas, it seems that the introduction of the basic elements of Qt Quick can only be put to the next time ...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.