SlideShare a Scribd company logo
Ring Documentation, Release 1.7
Method Name Class Name
setKeyPressEvent(cEvent) QAllEvents
setMouseButtonPressEvent(cEvent)
setMouseButtonReleaseEvent(cEvent)
setMouseButtonDblClickEvent(cEvent)
setMouseMoveEvent(cEvent)
setCloseEvent(cEvent)
setContextMenuEvent(cEvent)
setDragEnterEvent(cEvent)
setDragLeaveEvent(cEvent)
setDragMoveEvent(cEvent)
setDropEvent(cEvent)
setEnterEvent(cEvent)
setFocusInEvent(cEvent)
setFocusOutEvent(cEvent)
setKeyReleaseEvent(cEvent)
setLeaveEvent(cEvent)
setNonClientAreaMouseButtonDblClickEvent(cEvent)
setNonClientAreaMouseButtonPressEvent(cEvent)
setNonClientAreaMouseButtonReleaseEvent(cEvent)
setNonClientAreaMouseMoveEvent(cEvent)
setMoveEvent(cEvent)
setResizeEvent(cEvent)
setWindowActivateEvent(cEvent)
setWindowBlockedEvent(cEvent)
setWindowDeactivateEvent(cEvent)
setWindowStateChangeEvent(cEvent)
setWindowUnblockedEvent(cEvent)
59.58 The Difference between Qt and RingQt
1. RingQt use simple methods to set the code that will be executed for events.
Syntax:
Set<Event_Name>Event(cEventCode)
2. RingQt change the name of some methods to avoid conflict with Ring Keywords.
The next table present these little changes
59.58. The Difference between Qt and RingQt 712
Ring Documentation, Release 1.7
Class Name Qt Method Name RingQt Method Name
QWebView load loadpage
QMediaPlaylist load loadfile
QMediaPlaylist next movenext
QPainter end endpaint
QPicture load loadfile
QLineEdit end endtext
QDialog done donedialog
QTextDocument end enddoc
QTextBlock next nextblock
QSqlQuery next movenext
QImage load loadimage
QNetworkAccessManager get getvalue
QNetworkAccessManager put putvalue
QThread exit exitfromthread
QRegularExpressionMatchIterator next nextitem
QCamera load loadcamera
59.59 RingQt Classes and their Qt Documentation
Qt Documentation : http://doc.qt.io/qt-5/classes.html
See the “RingQt Classes and Methods Reference” chapter for supported classes and methods.
59.60 New Classes names - Index Start from 1
We added new classes to RingQt - another version of classes where the class names doesn’t start with the “q” letter
Also updated methods so the index start from 1 when we deal with the GUI controls like
• ComboBox
• ListWidget
• TableWidget
• TreeWidget
These classes are inside guilib.ring under the package name : System.GUI
To use it
load "guilib.ring"
import System.GUI
This doesn’t have any effect on our previous code, It’s just another choice for better code that is consistent with Ring
rules.
Also the form designer is updated to provide us the choice between using classes where (index start from 0) or (index
start from 1)
Example (Uses the Form Designer)
1. https://github.com/ring-lang/ring/blob/master/applications/formdesigner/tests/indexstart/indexstartView.ring
2. https://github.com/ring-lang/ring/blob/master/applications/formdesigner/tests/indexstart/indexstartController.ring
59.59. RingQt Classes and their Qt Documentation 713
Ring Documentation, Release 1.7
59.61 Creating Reports using the WebLib and the GUILib
The WebLib comes with a class called HtmlPage
Using this class we can create reports quickly using WebLib & GUILib together
Example:
load "stdlib.ring"
load "weblib.ring"
load "guilib.ring"
import System.Web
import System.GUI
new qApp {
open_window(:CustomersReportController)
exec()
}
class CustomersReportController
oView = new CustomersReportView
func Start
CreateReport()
func CreateReport
mypage = new HtmlPage {
h1 { text("Customers Report") }
Table
{
style = stylewidth("100%") + stylegradient(4)
TR
{
TD { WIDTH="10%"
text("Customers Count : " ) }
TD { text (100) }
}
}
Table
{
style = stylewidth("100%") + stylegradient(26)
TR
{
style = stylewidth("100%") +
stylegradient(24)
TD { text("Name " ) }
TD { text("Age" ) }
TD { text("Country" ) }
TD { text("Job" ) }
TD { text("Company" ) }
}
for x = 1 to 100
TR
{
TD { text("Test" ) }
TD { text("30" ) }
TD { text("Egypt" ) }
59.61. Creating Reports using the WebLib and the GUILib 714
Ring Documentation, Release 1.7
TD { text("Sales" ) }
TD { text("Future" ) }
}
next
}
}
write("report.html",mypage.output())
func PrintEvent
printer1 = new qPrinter(0) {
setoutputformat(1)
setoutputfilename("report.pdf")
}
oView {
web.print(printer1)
web.show()
}
system ("report.pdf")
class CustomersReportView
win = new window() {
setwindowtitle("Report Window")
setgeometry(100,100,500,500)
web = new webview(win) {
setgeometry(100,100,1000,500)
loadpage(new qurl("file:///"+
currentdir()+"/report.html"))
}
new pushbutton(win) {
setGeometry(100,20,100,30)
settext("Print")
setclickevent(Method(:PrintEvent))
}
showMaximized()
}
Screen Shot:
59.61. Creating Reports using the WebLib and the GUILib 715
Ring Documentation, Release 1.7
59.61. Creating Reports using the WebLib and the GUILib 716
CHAPTER
SIXTY
BUILDING RINGQT APPLICATIONS FOR MOBILE
In this chapter we will learn about Building RingQt Applications for Mobile.
60.1 Download Requirements
Check the next link : http://doc.qt.io/qt-5/androidgs.html
Download
• The Android SDK Tools
https://developer.android.com/studio/index.html
• The Android NDK (Tested using android-ndk-r10c)
https://developer.android.com/ndk/index.html
• Apache Ant v1.8 or later
http://ant.apache.org/bindownload.cgi
• Java SE Development Kit (JDK) v6 or later
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
60.2 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.
1. JAVA_HOME
For Example : C:Program Files (x86)Javajdk1.8.0_05
2. ANDROID_HOME
For Example : B:mahmoudToolsJava-Androidadt-bundle-windows-x86-20140702sdk
717
Ring Documentation, Release 1.7
60.3 Install Qt for Android
• You can install Qt for Android from the next link
https://download.qt.io/archive/qt/5.5/5.5.1/
• Run Qt Creator, Select Tools > Options > Android to add the Android NDK and SDK paths.
http://doc.qt.io/qtcreator/creator-developing-android.html
• Using Qt Creator Open the project
Folder : ring/android/ringqt/project
Project file : project.pro
• Using Qt Creator, You will find the compiled Ring application in resources/ringapp.ringo
This file (Ring Object File) is generated by the Ring compiler using
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
Example
if isandroid()
mypic = new QPixmap(":/cards.jpg")
else
mypic = new QPixmap("cards.jpg")
ok
3. In your Ring application folder (Using the command prompt)
ring myapp.ring -go -norun
4. Add your file to the project project/myapp.ringo
5. Update main.cpp and project.qrc and replace ringapp.ringo with myapp.ringo
6. Build and Run your Application using Qt Creator
60.3. Install Qt for Android 718
Ring Documentation, Release 1.7
60.4 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
Note: All of the missing libraries ((LibCurl, OpenSSL & Allegro) can be compiled for Android, but they are not
included in this Qt project.
3. use if isandroid() when you want to modify the code just for android
Example:
if isandroid()
// Android code
60.4. Comments about developing for Android using RingQt 719
Ring Documentation, Release 1.7
else
// other platforms
ok
(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()
setStyleSheet("
border-style: outset;
border-width: 2px;
border-radius: 4px;
border-color: black;
padding: 6px;")
ok
5. 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)
6. When you deal with Qt Classes you can determine the images from resources (you don’t need to copy them
using main.cpp)
Example:
if isandroid()
mypic = new QPixmap(":/cards.jpg")
else
mypic = new QPixmap("cards.jpg")
ok
Now RingQt comes with the AppFile() function to determine the file name
Example:
mypic = new QPixmap(AppFile("cards.jpg")) # Desktop or Android
60.5 Using Ring2EXE
Starting from Ring 1.6 we can use Ring2EXE to quickly prepare Qt project for our application
Example:
ring2exe myapp.ring -dist -mobileqt
60.5. Using Ring2EXE 720
CHAPTER
SIXTYONE
OBJECTS LIBRARY FOR RINGQT APPLICATION
In this chapter we will learn about the objects library for RingQt applications.
Ring comes with the Objects library for RingQt applications. Instead of using global variables for windows objects
and connecting events to objects using the object name, the Objects Library will manage the GUI objects and will
provide a more natural API to quickly create one or many windows from the same class and the library provide a way
to quickly set methods to be executed when an event is fired. Also the library provide a natural interface to quickly
use the parent or the caller windows from the child or sub windows.
The Objects Library is designed to be used with the MVC Design Pattern.
The Objects Library is merged in RingQt so you can use it directly when you use RingQt
61.1 Library Usage
• Use the Open_Window(cWindowControllerClassName) function to open new Windows
• Create at least Two Classes for each window, The Controller Class and the View Class
• Create each controller class from the WindowsControllerParent Class
• Create each view class from the WindowsViewParent Class
• Use the Last_Window() function to get the object of the last window created (The Controller object).
• When you call a sub window, use the SetParentObject() method and pass the self object.
• In the View Class, To determine the event method use the Method(cMethodName) function.
• The Method(cMethodName) function determine the method in the controller class that will be executed.
• Each controller class contains by default the CloseAction() method that you can call to close the window.
• You don’t need to call the Show() Method for each window, When you use Open_Window() It will be called.
• In the view class, Define the GUI window object as an attribute called win.
• You can use Open_WindowNoShow() to avoid displaying the window.
• You can use Open_WindowAndLink() to quickly get methods to access the windows.
61.2 Example
In the next example we will create two types of windows.
• Main Window contains a button. When the user click on the button a sub window will be opened.
721

More Related Content

PDF
The Ring programming language version 1.8 book - Part 77 of 202
PDF
The Ring programming language version 1.5 book - Part 12 of 31
PDF
The Ring programming language version 1.7 book - Part 8 of 196
PDF
The Ring programming language version 1.10 book - Part 82 of 212
PDF
The Ring programming language version 1.2 book - Part 51 of 84
PDF
A friend in need - A JS indeed
PDF
The Ring programming language version 1.7 book - Part 82 of 196
PDF
The Ring programming language version 1.4 book - Part 19 of 30
The Ring programming language version 1.8 book - Part 77 of 202
The Ring programming language version 1.5 book - Part 12 of 31
The Ring programming language version 1.7 book - Part 8 of 196
The Ring programming language version 1.10 book - Part 82 of 212
The Ring programming language version 1.2 book - Part 51 of 84
A friend in need - A JS indeed
The Ring programming language version 1.7 book - Part 82 of 196
The Ring programming language version 1.4 book - Part 19 of 30

What's hot (20)

PDF
PVS-Studio in the Clouds: CircleCI
PDF
The Ring programming language version 1.10 book - Part 72 of 212
PDF
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
PDF
The Ring programming language version 1.8 book - Part 10 of 202
PPTX
Dependency Injection for Android
PPTX
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
PDF
Android programming -_pushing_the_limits
PDF
droidparts
PDF
The Ring programming language version 1.6 book - Part 80 of 189
PDF
The Ring programming language version 1.8 book - Part 85 of 202
PDF
Docker In Bank Unrated
PDF
The Ring programming language version 1.5.2 book - Part 68 of 181
PDF
The Ring programming language version 1.9 book - Part 9 of 210
PDF
Android Unit Testing With Robolectric
PDF
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
PDF
QThreads: Are You Using Them Wrong?
 
PDF
JavaOne 2017 - TestContainers: integration testing without the hassle
PDF
Dependency Injection on Android
PDF
Qt multi threads
PVS-Studio in the Clouds: CircleCI
The Ring programming language version 1.10 book - Part 72 of 212
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
The Ring programming language version 1.8 book - Part 10 of 202
Dependency Injection for Android
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Android programming -_pushing_the_limits
droidparts
The Ring programming language version 1.6 book - Part 80 of 189
The Ring programming language version 1.8 book - Part 85 of 202
Docker In Bank Unrated
The Ring programming language version 1.5.2 book - Part 68 of 181
The Ring programming language version 1.9 book - Part 9 of 210
Android Unit Testing With Robolectric
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
QThreads: Are You Using Them Wrong?
 
JavaOne 2017 - TestContainers: integration testing without the hassle
Dependency Injection on Android
Qt multi threads
Ad

Similar to The Ring programming language version 1.7 book - Part 75 of 196 (20)

PDF
The Ring programming language version 1.9 book - Part 81 of 210
PDF
The Ring programming language version 1.10 book - Part 83 of 212
PDF
The Ring programming language version 1.6 book - Part 73 of 189
PDF
The Ring programming language version 1.5.4 book - Part 71 of 185
PDF
The Ring programming language version 1.5.1 book - Part 67 of 180
PDF
The Ring programming language version 1.3 book - Part 53 of 88
PDF
The Ring programming language version 1.10 book - Part 91 of 212
PDF
The Ring programming language version 1.5.3 book - Part 12 of 184
PDF
The Ring programming language version 1.9 book - Part 18 of 210
PDF
The Ring programming language version 1.5.3 book - Part 81 of 184
PDF
The Ring programming language version 1.8 book - Part 16 of 202
PDF
The Ring programming language version 1.9 book - Part 12 of 210
PDF
The Ring programming language version 1.8 book - Part 199 of 202
PDF
The Ring programming language version 1.10 book - Part 13 of 212
PDF
The Ring programming language version 1.6 book - Part 189 of 189
PDF
The Ring programming language version 1.10 book - Part 208 of 212
PDF
The Ring programming language version 1.8 book - Part 201 of 202
PDF
The Ring programming language version 1.10 book - Part 18 of 212
PDF
The Ring programming language version 1.4.1 book - Part 16 of 31
PDF
The Ring programming language version 1.5.2 book - Part 181 of 181
The Ring programming language version 1.9 book - Part 81 of 210
The Ring programming language version 1.10 book - Part 83 of 212
The Ring programming language version 1.6 book - Part 73 of 189
The Ring programming language version 1.5.4 book - Part 71 of 185
The Ring programming language version 1.5.1 book - Part 67 of 180
The Ring programming language version 1.3 book - Part 53 of 88
The Ring programming language version 1.10 book - Part 91 of 212
The Ring programming language version 1.5.3 book - Part 12 of 184
The Ring programming language version 1.9 book - Part 18 of 210
The Ring programming language version 1.5.3 book - Part 81 of 184
The Ring programming language version 1.8 book - Part 16 of 202
The Ring programming language version 1.9 book - Part 12 of 210
The Ring programming language version 1.8 book - Part 199 of 202
The Ring programming language version 1.10 book - Part 13 of 212
The Ring programming language version 1.6 book - Part 189 of 189
The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.8 book - Part 201 of 202
The Ring programming language version 1.10 book - Part 18 of 212
The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.5.2 book - Part 181 of 181
Ad

More from Mahmoud Samir Fayed (20)

PDF
The Ring programming language version 1.10 book - Part 212 of 212
PDF
The Ring programming language version 1.10 book - Part 211 of 212
PDF
The Ring programming language version 1.10 book - Part 210 of 212
PDF
The Ring programming language version 1.10 book - Part 207 of 212
PDF
The Ring programming language version 1.10 book - Part 205 of 212
PDF
The Ring programming language version 1.10 book - Part 206 of 212
PDF
The Ring programming language version 1.10 book - Part 204 of 212
PDF
The Ring programming language version 1.10 book - Part 203 of 212
PDF
The Ring programming language version 1.10 book - Part 202 of 212
PDF
The Ring programming language version 1.10 book - Part 201 of 212
PDF
The Ring programming language version 1.10 book - Part 200 of 212
PDF
The Ring programming language version 1.10 book - Part 199 of 212
PDF
The Ring programming language version 1.10 book - Part 198 of 212
PDF
The Ring programming language version 1.10 book - Part 197 of 212
PDF
The Ring programming language version 1.10 book - Part 196 of 212
PDF
The Ring programming language version 1.10 book - Part 195 of 212
PDF
The Ring programming language version 1.10 book - Part 194 of 212
PDF
The Ring programming language version 1.10 book - Part 193 of 212
PDF
The Ring programming language version 1.10 book - Part 192 of 212
PDF
The Ring programming language version 1.10 book - Part 191 of 212
The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 211 of 212
The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 205 of 212
The Ring programming language version 1.10 book - Part 206 of 212
The Ring programming language version 1.10 book - Part 204 of 212
The Ring programming language version 1.10 book - Part 203 of 212
The Ring programming language version 1.10 book - Part 202 of 212
The Ring programming language version 1.10 book - Part 201 of 212
The Ring programming language version 1.10 book - Part 200 of 212
The Ring programming language version 1.10 book - Part 199 of 212
The Ring programming language version 1.10 book - Part 198 of 212
The Ring programming language version 1.10 book - Part 197 of 212
The Ring programming language version 1.10 book - Part 196 of 212
The Ring programming language version 1.10 book - Part 195 of 212
The Ring programming language version 1.10 book - Part 194 of 212
The Ring programming language version 1.10 book - Part 193 of 212
The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 191 of 212

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PPTX
Spectroscopy.pptx food analysis technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
sap open course for s4hana steps from ECC to s4
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
KodekX | Application Modernization Development
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Encapsulation theory and applications.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Approach and Philosophy of On baking technology
Spectroscopy.pptx food analysis technology
Per capita expenditure prediction using model stacking based on satellite ima...
sap open course for s4hana steps from ECC to s4
MIND Revenue Release Quarter 2 2025 Press Release
Review of recent advances in non-invasive hemoglobin estimation
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
KodekX | Application Modernization Development
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
MYSQL Presentation for SQL database connectivity
Unlocking AI with Model Context Protocol (MCP)
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Weekly Chronicles - August'25 Week I
The AUB Centre for AI in Media Proposal.docx
Encapsulation theory and applications.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Dropbox Q2 2025 Financial Results & Investor Presentation

The Ring programming language version 1.7 book - Part 75 of 196

  • 1. Ring Documentation, Release 1.7 Method Name Class Name setKeyPressEvent(cEvent) QAllEvents setMouseButtonPressEvent(cEvent) setMouseButtonReleaseEvent(cEvent) setMouseButtonDblClickEvent(cEvent) setMouseMoveEvent(cEvent) setCloseEvent(cEvent) setContextMenuEvent(cEvent) setDragEnterEvent(cEvent) setDragLeaveEvent(cEvent) setDragMoveEvent(cEvent) setDropEvent(cEvent) setEnterEvent(cEvent) setFocusInEvent(cEvent) setFocusOutEvent(cEvent) setKeyReleaseEvent(cEvent) setLeaveEvent(cEvent) setNonClientAreaMouseButtonDblClickEvent(cEvent) setNonClientAreaMouseButtonPressEvent(cEvent) setNonClientAreaMouseButtonReleaseEvent(cEvent) setNonClientAreaMouseMoveEvent(cEvent) setMoveEvent(cEvent) setResizeEvent(cEvent) setWindowActivateEvent(cEvent) setWindowBlockedEvent(cEvent) setWindowDeactivateEvent(cEvent) setWindowStateChangeEvent(cEvent) setWindowUnblockedEvent(cEvent) 59.58 The Difference between Qt and RingQt 1. RingQt use simple methods to set the code that will be executed for events. Syntax: Set<Event_Name>Event(cEventCode) 2. RingQt change the name of some methods to avoid conflict with Ring Keywords. The next table present these little changes 59.58. The Difference between Qt and RingQt 712
  • 2. Ring Documentation, Release 1.7 Class Name Qt Method Name RingQt Method Name QWebView load loadpage QMediaPlaylist load loadfile QMediaPlaylist next movenext QPainter end endpaint QPicture load loadfile QLineEdit end endtext QDialog done donedialog QTextDocument end enddoc QTextBlock next nextblock QSqlQuery next movenext QImage load loadimage QNetworkAccessManager get getvalue QNetworkAccessManager put putvalue QThread exit exitfromthread QRegularExpressionMatchIterator next nextitem QCamera load loadcamera 59.59 RingQt Classes and their Qt Documentation Qt Documentation : http://doc.qt.io/qt-5/classes.html See the “RingQt Classes and Methods Reference” chapter for supported classes and methods. 59.60 New Classes names - Index Start from 1 We added new classes to RingQt - another version of classes where the class names doesn’t start with the “q” letter Also updated methods so the index start from 1 when we deal with the GUI controls like • ComboBox • ListWidget • TableWidget • TreeWidget These classes are inside guilib.ring under the package name : System.GUI To use it load "guilib.ring" import System.GUI This doesn’t have any effect on our previous code, It’s just another choice for better code that is consistent with Ring rules. Also the form designer is updated to provide us the choice between using classes where (index start from 0) or (index start from 1) Example (Uses the Form Designer) 1. https://github.com/ring-lang/ring/blob/master/applications/formdesigner/tests/indexstart/indexstartView.ring 2. https://github.com/ring-lang/ring/blob/master/applications/formdesigner/tests/indexstart/indexstartController.ring 59.59. RingQt Classes and their Qt Documentation 713
  • 3. Ring Documentation, Release 1.7 59.61 Creating Reports using the WebLib and the GUILib The WebLib comes with a class called HtmlPage Using this class we can create reports quickly using WebLib & GUILib together Example: load "stdlib.ring" load "weblib.ring" load "guilib.ring" import System.Web import System.GUI new qApp { open_window(:CustomersReportController) exec() } class CustomersReportController oView = new CustomersReportView func Start CreateReport() func CreateReport mypage = new HtmlPage { h1 { text("Customers Report") } Table { style = stylewidth("100%") + stylegradient(4) TR { TD { WIDTH="10%" text("Customers Count : " ) } TD { text (100) } } } Table { style = stylewidth("100%") + stylegradient(26) TR { style = stylewidth("100%") + stylegradient(24) TD { text("Name " ) } TD { text("Age" ) } TD { text("Country" ) } TD { text("Job" ) } TD { text("Company" ) } } for x = 1 to 100 TR { TD { text("Test" ) } TD { text("30" ) } TD { text("Egypt" ) } 59.61. Creating Reports using the WebLib and the GUILib 714
  • 4. Ring Documentation, Release 1.7 TD { text("Sales" ) } TD { text("Future" ) } } next } } write("report.html",mypage.output()) func PrintEvent printer1 = new qPrinter(0) { setoutputformat(1) setoutputfilename("report.pdf") } oView { web.print(printer1) web.show() } system ("report.pdf") class CustomersReportView win = new window() { setwindowtitle("Report Window") setgeometry(100,100,500,500) web = new webview(win) { setgeometry(100,100,1000,500) loadpage(new qurl("file:///"+ currentdir()+"/report.html")) } new pushbutton(win) { setGeometry(100,20,100,30) settext("Print") setclickevent(Method(:PrintEvent)) } showMaximized() } Screen Shot: 59.61. Creating Reports using the WebLib and the GUILib 715
  • 5. Ring Documentation, Release 1.7 59.61. Creating Reports using the WebLib and the GUILib 716
  • 6. CHAPTER SIXTY BUILDING RINGQT APPLICATIONS FOR MOBILE In this chapter we will learn about Building RingQt Applications for Mobile. 60.1 Download Requirements Check the next link : http://doc.qt.io/qt-5/androidgs.html Download • The Android SDK Tools https://developer.android.com/studio/index.html • The Android NDK (Tested using android-ndk-r10c) https://developer.android.com/ndk/index.html • Apache Ant v1.8 or later http://ant.apache.org/bindownload.cgi • Java SE Development Kit (JDK) v6 or later http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html 60.2 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. 1. JAVA_HOME For Example : C:Program Files (x86)Javajdk1.8.0_05 2. ANDROID_HOME For Example : B:mahmoudToolsJava-Androidadt-bundle-windows-x86-20140702sdk 717
  • 7. Ring Documentation, Release 1.7 60.3 Install Qt for Android • You can install Qt for Android from the next link https://download.qt.io/archive/qt/5.5/5.5.1/ • Run Qt Creator, Select Tools > Options > Android to add the Android NDK and SDK paths. http://doc.qt.io/qtcreator/creator-developing-android.html • Using Qt Creator Open the project Folder : ring/android/ringqt/project Project file : project.pro • Using Qt Creator, You will find the compiled Ring application in resources/ringapp.ringo This file (Ring Object File) is generated by the Ring compiler using 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 Example if isandroid() mypic = new QPixmap(":/cards.jpg") else mypic = new QPixmap("cards.jpg") ok 3. In your Ring application folder (Using the command prompt) ring myapp.ring -go -norun 4. Add your file to the project project/myapp.ringo 5. Update main.cpp and project.qrc and replace ringapp.ringo with myapp.ringo 6. Build and Run your Application using Qt Creator 60.3. Install Qt for Android 718
  • 8. Ring Documentation, Release 1.7 60.4 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 Note: All of the missing libraries ((LibCurl, OpenSSL & Allegro) can be compiled for Android, but they are not included in this Qt project. 3. use if isandroid() when you want to modify the code just for android Example: if isandroid() // Android code 60.4. Comments about developing for Android using RingQt 719
  • 9. Ring Documentation, Release 1.7 else // other platforms ok (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() setStyleSheet(" border-style: outset; border-width: 2px; border-radius: 4px; border-color: black; padding: 6px;") ok 5. 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) 6. When you deal with Qt Classes you can determine the images from resources (you don’t need to copy them using main.cpp) Example: if isandroid() mypic = new QPixmap(":/cards.jpg") else mypic = new QPixmap("cards.jpg") ok Now RingQt comes with the AppFile() function to determine the file name Example: mypic = new QPixmap(AppFile("cards.jpg")) # Desktop or Android 60.5 Using Ring2EXE Starting from Ring 1.6 we can use Ring2EXE to quickly prepare Qt project for our application Example: ring2exe myapp.ring -dist -mobileqt 60.5. Using Ring2EXE 720
  • 10. CHAPTER SIXTYONE OBJECTS LIBRARY FOR RINGQT APPLICATION In this chapter we will learn about the objects library for RingQt applications. Ring comes with the Objects library for RingQt applications. Instead of using global variables for windows objects and connecting events to objects using the object name, the Objects Library will manage the GUI objects and will provide a more natural API to quickly create one or many windows from the same class and the library provide a way to quickly set methods to be executed when an event is fired. Also the library provide a natural interface to quickly use the parent or the caller windows from the child or sub windows. The Objects Library is designed to be used with the MVC Design Pattern. The Objects Library is merged in RingQt so you can use it directly when you use RingQt 61.1 Library Usage • Use the Open_Window(cWindowControllerClassName) function to open new Windows • Create at least Two Classes for each window, The Controller Class and the View Class • Create each controller class from the WindowsControllerParent Class • Create each view class from the WindowsViewParent Class • Use the Last_Window() function to get the object of the last window created (The Controller object). • When you call a sub window, use the SetParentObject() method and pass the self object. • In the View Class, To determine the event method use the Method(cMethodName) function. • The Method(cMethodName) function determine the method in the controller class that will be executed. • Each controller class contains by default the CloseAction() method that you can call to close the window. • You don’t need to call the Show() Method for each window, When you use Open_Window() It will be called. • In the view class, Define the GUI window object as an attribute called win. • You can use Open_WindowNoShow() to avoid displaying the window. • You can use Open_WindowAndLink() to quickly get methods to access the windows. 61.2 Example In the next example we will create two types of windows. • Main Window contains a button. When the user click on the button a sub window will be opened. 721