QT for Android HelloWorld implementation

Source: Internet
Author: User

1 New Project

Open Qt Creator, file-and new file or project; In the dialog box, select "Android template"->application->qt Widgets application
Then click on "Choose ..."

Set the "name" and "Create path", if you feel it is necessary to "set as the default project path" on the hook;

In "Qt Widgets application", I suggest "desktop" and "Android" two, because we can debug in "desktop", some people say why not use Android virtual machine? Personally feel that too slow, wasting time, under Windows debugging completed, to Android inside the basic will not change too much, and in Windows debugging speed is not said super fast, but compared with Android virtual machine, it is really a sky, an underground.
Other according to their actual situation to configure, my configuration is as follows, for reference only:

In the next configuration, we select the base class: Qdialog, tick "Create Interface", and complete next.
At this point, the new project has finished, began to implement the HelloWorld function.

HelloWorld function implementation

In the interface file there is a "dialog.ui" file, double-click to enter the interface design.
Insert a Label control: the leftmost control bar, "Display Widgets", "Label", drag directly into the dialog box, the "Textlabel" will appear, next double-click, you can edit it, enter "Hello world!";
If these are not satisfied, you can set their properties, the rightmost property bar, set up, after the setup is complete, save;

Compilation mode selection

As mentioned earlier, why should we choose the desktop for debugging purposes?
Let's start by selecting the Windows-debug mode for the build, as shown in:

Then click on the Blue triangle, start the debug program compile and run, if there is an error, please go back to "Qt for Android Environment build" to view the issue.
If the result, the compilation results are out, as shown in:

Below, we begin to enter the Android compilation mode, similarly, in the previous step, we selected "Android for armeabi-v7a (Gcc 4.8,qt 5.4.1)", "Debug";
In this compilation, we only choose to build (that is, the little hammer icon at the bottom).

Precautions

Due to the problem of screen size of mobile phone, we need to set the program interface to fit the screen size of mobile phone, back to "Dialog.ui" interface design. Check the interface, in the geometry, the height and width set to fit your phone mode, my phone for 720x1280, because the mobile phone has a notification bar, we need to notice the height of the bar also take into account, I here will be the actual height minus 50, to get the height of the program 720x1230, save, Select the Android Compilation tool to build.
After the successful compilation, will be in the Hello\andriod-debug\android-build\bin directory production of a qtapp-debug.apk, copy it into the phone, installation can run to see the effect.

Hellowold to this end, I hope you have a lot of advice.

QT for Android HelloWorld implementation

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.