Building RingQt Applications for Mobile

In this chapter we will learn about Building RingQt Applications for Mobile.

Download Requirements

Check the next link :


Update the Android SDK

Update the Android SDK to get the API and tools packages required for development

Tested using Android 4.4.2 (API 19)
  • In Windows - Define the next Environment Variables based on your system.
For Example : C:\Program Files (x86)\Java\jdk1.8.0_05
For Example : B:\mahmoud\Tools\Java-Android\adt-bundle-windows-x86-20140702\sdk

Install Qt for Android

ring ringapp.ring -go -norun
  • To run your application instead of the default application
  1. Using Qt Creator, Add your application images to resources

    Or You can use any text editor (Notepad) and modify : project.qrc

  2. To find images from your Ring application, You need to use the file name in resources


if isandroid()
        mypic = new QPixmap(":/cards.jpg")
        mypic = new QPixmap("cards.jpg")
  1. In your Ring application folder (Using the command prompt)
ring myapp.ring -go -norun
  1. Add your file to the project project/myapp.ringo
  2. Update main.cpp and project.qrc and replace ringapp.ringo with myapp.ringo
  3. Build and Run your Application using Qt Creator
RingQt for Android

Comments about developing for Android using RingQt

  1. The main project file is main.cpp

    This file load Ring Compiler/Virtual Machine and RingQt

    Then copy the Ring Object File during the runtime from the resources to temp. folder

    Then run the Ring Object File (ringapp.ringo) using the Ring VM

    Through main.cpp you can extract more files from the resources to temp. folder once you add them (create projects with many files).

  2. The next functions are missing from this Ring edition

    • Database (ODBC, SQLite & MySQL)
    • Security and Internet functions (LibCurl & OpenSSL)
    • RingAllegro (Allegro Library)
    • RingLibSDL (LibSDL Library)

    Just use Qt Classes through RingQt.

    For database access use the QSqlDatabase Class


All of the missing libraries ((LibCurl, OpenSSL & Allegro) can be compiled for Android, but they are not included in this Qt project.

  1. use if isandroid() when you want to modify the code just for android


if isandroid()
        // Android code
        // other platforms

(4) Sometimes you will find that the button text/image is repeated in drawing ! it’s Qt problem that you can avoid using the next code.

if isandroid()
                border-style: outset;
                border-width: 2px;
                border-radius: 4px;
                border-color: black;
                padding: 6px;")
  1. Always use Layouts instead of manual setting of controls position and size.

This is the best way to get the expected user interface to avoid problems like (controls with small/extra size)

  1. When you deal with Qt Classes you can determine the images from resources (you don’t need to copy them using main.cpp)


if isandroid()
    mypic = new QPixmap(":/cards.jpg")
    mypic = new QPixmap("cards.jpg")

Now RingQt comes with the AppFile() function to determine the file name


mypic = new QPixmap(AppFile("cards.jpg"))  # Desktop or Android

Using Ring2EXE

Starting from Ring 1.6 we can use Ring2EXE to quickly prepare Qt project for our application


ring2exe myapp.ring -dist -mobileqt