Necessitas-let you enjoy QT on Android!

Source: Internet
Author: User
Http://gaolinjie.blog.cd/index.php/2011/10/30/necessitas/ first came into contact with QT because it was very interested in meego development, but not Xin Nokia and Intel have abandoned this let me look forward to mobile operating systems. I believe that anyone who has developed QT will think that this is a very good development environment, however, what is embarrassing is that it cannot be well applied to the hottest mobile development field today (although QT supports Symbian and embedded Linux, ...). Fortunately, the Romanian Bogdan Vatra uses necessitas to bring QT to Android-the mobile operating system with the largest market share today.
Currently, necessitas is still in the Alpha stage, which may cause minor problems during its configuration. But how can we more deeply experience the joy of success without being overwhelmed? The so-called, life is tossing! Let's take a look at the specific steps for configuring necessitas!
I installed necessitas on Ubuntu 11.04. Of course, it also supports Windows and Mac platforms.

Step #1: Install ant and JDK enter: sudo apt-Get install antsudo apt-Get install openjdk-6-jdk in the terminal
You can also search for ant and openjdk in the new version to choose to install:
Step #2: Install the android SDK and Android ndk from the http://developer.android.com/sdk/index.html to download the latest SDK, move the downloaded file to the Home Directory, open the terminal and enter the following command:
Tar-XF android-sdk_r14-linux.tgzandroid-sdk */tools/android
On the pop-up installation page, select Tools and Android 2.3.3 (API 10) for installation:

Download the latest ndk from the http://developer.android.com/sdk/ndk/index.html, also move the downloaded file to the Home Directory, enter the following command on the terminal:


Tar-XF android-ndk-r6b-linux-x86.tar.bz2
In this way, the ndk is extracted to the main directory.
Step #3: Install the necessitas SDK
Now the latest version of necessitas is alpha2. I have installed it before, but the created application cannot display Chinese characters. I have found a lot of information on the Internet for this problem, but it has never been solved. I had to go to the Google forum of necessitas to ask for help. The enthusiastic Bogdan Vatra gave me an unofficially released alpha3 version, after my tests, I found that this version can display Chinese characters perfectly.
Necessitas alpha3: http://files.kde.org/necessitas/installer/
Double-click the downloaded necessitas installation package and the installation page will pop up: You can choose to install modules, including Android SDK, ndk, and ant, but it may be caused by network speed, if you select these three components, you will find that the installation time will be particularly long, so I recommend that you do not choose these three components, instead, manually install the SDK by following steps #1 and #2. (Of course, you can also try to install only JDK in step #1 and #2, and then install these three items in this step. If the network speed is good, it may simplify your installation steps)
Step #4: necessitas QT creator settings
Select necessitas QT creator from the programming menu of ubuntu to open the necessitas development environment, select Tools> options in the menu bar, and select android on the left of the displayed dialog box, follow the path of the Configuration tool: Step #5: Install Ministro on the Android device

Also download the latest ministroservice.apk and ministroconfigurationtool.apk in the http://files.kde.org/necessitas/installer/ and copy them ~ /Android-SDK-Linux/platform-tools/directory. in the terminal, the directory CD is also under this directory, run the following command to install these two APK files on your mobile phone:

Sudo./ADB install ministroservice.apk

Sudo./ADB install ministroconfigurationtool.apk

Step #6: Create a Chinese version of the test program 1. Open necessitas QT creator, select File-> New file or project ..., In the displayed dialog box, select other project> Empty QT project:

Enter the project name, select the Android platform, and click Finish to complete the creation.

2. The new Hello project is as follows:

3. Create main. cpp:

Program code:

# Include <qtgui/qapplication>
# Include <qtdeclarative/qdeclarativeview>

Int main (INT argc, char * argv [])
{
Qapplication A (argc, argv );

Qdeclarativeview view;
View. setsource (qurl ("qrc: Ui. qml "));

View. Show ();

Return a.exe C ();
}

4. Add the QT module used in hello. Pro:

5. Create UI. qml:

Program code:

Import qtquick 1.0

Rectangle {
Width: 480; Height: 800

Image {
ID: Background
Source: “qt.png"
Anchors. Centerin: parent

Text {
ID: txt
Anchors. horizontalcenter: parent. horizontalcenter
Y: 100
Font. pointsize: 22
Text: "Hello QT !"
Color: "red"

Mousearea {
Anchors. Fill: parent
Onclicked :{
TXT. Text = "Hello Chinese !"
}
}
}
}
}

6. Create resource. qrc

7. Add UI. qml and qt.png to the Resource System:

8. finally run the program.


The program runs on my Nexus One as follows: "Hello QT !" The text will become "Hello Chinese !" :

2011, gaolinjie. All rights reserved.

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.