SlideShare a Scribd company logo
1 of 10
Download to read offline
Ring Documentation, Release 1.2
Table 47.1 – continued from previous page
Class Name Methods to use the default Events
QTcpServer SetAcceptErrorEvent()
SetNewConnectionEvent()
QIODevice SetAboutToCloseEvent()
SetBytesWrittenEvent()
SetReadChannelFinishedEvent()
SetReadyReadEvent()
QAbstractSocket SetConnectedEvent()
SetDisconnectedEvent()
SetErrorEvent()
SetHostFoundEvent()
SetProxyAuthenticationRequiredEvent()
SetStateChangedEvent()
QTcpSocket SetConnectedEvent()
SetDisconnectedEvent()
SetErrorEvent()
SetHostFoundEvent()
SetProxyAuthenticationRequiredEvent()
SetStateChangedEvent()
SetAboutToCloseEvent()
SetBytesWrittenEvent()
SetReadChannelFinishedEvent()
SetReadyReadEvent()
QColorDialog SetColorSelectedEvent()
SetCurrentColorChangedEvent()
QNetworkAccessManager SetFinishedEvent()
QThread SetStartedEvent()
SetFinishedEvent()
47.55 Methods to use Events with Events Filter
RingQt define a new class called QAllEvents that help you in using Events Filter
The next table presents the methods that we have
Methods to get parameters Class Name
getKeyCode() –> Number QAllEvents
getx() –> Number
gety() –> Number
getglobalx() –> Number
getglobaly() –> Number
getbutton() –> Number
getbuttons() –> Number
The next table presents the methods that we have to use events.
47.55. Methods to use Events with Events Filter 480
Ring Documentation, Release 1.2
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)
47.56 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
47.56. The Difference between Qt and RingQt 481
Ring Documentation, Release 1.2
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
47.57 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.
47.57. RingQt Classes and their Qt Documentation 482
CHAPTER
FORTYEIGHT
BUILDING RINGQT APPLICATIONS FOR MOBILE
In this chapter we will learn about Building RingQt Applications for Mobile.
48.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
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
48.2 Update the Android SDK
Update the Android SDK to get the API and tools packages required for development
48.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
483
Ring Documentation, Release 1.2
• You will find the code in resourcestest.ring
You can modify the code then build and run for Desktop or Mobile.
48.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 files during the runtime from the resources to temp. folder
Then run the test.ring
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
48.4. Comments about developing for Android using RingQt 484
Ring Documentation, Release 1.2
Example:
if isandroid()
// Android code
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(":/resources/cardsimage")
else
mypic = new QPixmap("cards.jpg")
ok
In the previous example, cards.jpg is added to the resources then we write the “cardsimage” as alias for “cards.jpg”
48.4. Comments about developing for Android using RingQt 485
CHAPTER
FORTYNINE
OBJECTS LIBRARY FOR RINGQT APPLICATION
In this chapter we will learn about the objects library for RingQt applications.
Ring 1.2 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
49.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.
49.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.
• The User Can click on the button many times to open many sub windows.
• Each Sub Window contains Two buttons.
486
Ring Documentation, Release 1.2
• The first button in the sub window change the Main and the Sub Windows Titles.
• The second button in the sub window close the Sub Window.
load "guilib.ring"
new qApp {
open_window( :MainWindowController )
exec()
}
class MainWindowController from WindowsControllerParent
oView = new MainWindowView
func SubWindowAction
Open_window( :SubWindowController )
Last_Window().SetParentObject(self)
class MainWindowView from WindowsViewParent
win = new qWidget() {
SetWindowTitle("Main Window")
btnSub = new qPushButton(win) {
setText("Sub Window")
setClickEvent( Method( :SubWindowAction ) )
}
resize(400,400)
}
class SubWindowController from WindowsControllerParent
oView = new SubWindowView
func SetMainWindowTitleAction
Parent().oView.win.SetWindowTitle("Message from the Sub Window")
oView.win.SetWindowTitle("Click Event Done!")
class SubWindowView from WindowsViewParent
win = new qWidget() {
SetWindowTitle("Sub Window")
btnMsg = new qPushButton(win) {
setText("Set Main Window Title")
setClickEvent( Method( :SetMainWindowTitleAction ) )
}
btnClose = new qPushButton(win) {
Move(200,0)
setText("Close")
setClickEvent( Method( :CloseAction ) )
}
resize(400,400)
}
The next screen shot after creating three sub windows.
49.2. Example 487
Ring Documentation, Release 1.2
The next screen shot after clicking on the button in each sub window.
49.2. Example 488
Ring Documentation, Release 1.2
49.3 Objects Library Source Code
The library source code is very simple, You can check the source code files
• https://github.com/ring-lang/ring/blob/master/extensions/ringqt/objectslib/objects.ring
• https://github.com/ring-lang/ring/blob/master/extensions/ringqt/objectslib/subwindows.ring
# List of objects (Windows/Forms)
$RingQt_ObjectsList = [] # Contains sub lists [object ID , Object]
# The Object ID Counter
$RingQt_ObjectID = 0
# Variable used for Windows/Forms object name - used for setting events
$RingQt_ObjName = ""
# The next constants for the Objects List
C_RINGQT_OBJECTSLIST_ID = 1
49.3. Objects Library Source Code 489

More Related Content

What's hot

Automated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.xAutomated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.x
Tatsuya Maki
 

What's hot (20)

QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong?
 
The Ring programming language version 1.5.3 book - Part 81 of 184
The Ring programming language version 1.5.3 book - Part 81 of 184The Ring programming language version 1.5.3 book - Part 81 of 184
The Ring programming language version 1.5.3 book - Part 81 of 184
 
Qt multi threads
Qt multi threadsQt multi threads
Qt multi threads
 
Android Loaders : Reloaded
Android Loaders : ReloadedAndroid Loaders : Reloaded
Android Loaders : Reloaded
 
Logux, a new approach to client-server communication by Andrey Sitnik
Logux, a new approach to client-server communication by Andrey SitnikLogux, a new approach to client-server communication by Andrey Sitnik
Logux, a new approach to client-server communication by Andrey Sitnik
 
State of the Art OpenGL and Qt
State of the Art OpenGL and QtState of the Art OpenGL and Qt
State of the Art OpenGL and Qt
 
Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"Alexey Buzdin "Maslow's Pyramid of Android Testing"
Alexey Buzdin "Maslow's Pyramid of Android Testing"
 
The Ring programming language version 1.9 book - Part 81 of 210
The Ring programming language version 1.9 book - Part 81 of 210The Ring programming language version 1.9 book - Part 81 of 210
The Ring programming language version 1.9 book - Part 81 of 210
 
02 - Basics of Qt
02 - Basics of Qt02 - Basics of Qt
02 - Basics of Qt
 
Loaders (and why we should use them)
Loaders (and why we should use them)Loaders (and why we should use them)
Loaders (and why we should use them)
 
droidparts
droidpartsdroidparts
droidparts
 
Design patterns - Common Solutions to Common Problems - Brad Wood
Design patterns -  Common Solutions to Common Problems - Brad WoodDesign patterns -  Common Solutions to Common Problems - Brad Wood
Design patterns - Common Solutions to Common Problems - Brad Wood
 
The Ring programming language version 1.6 book - Part 7 of 189
The Ring programming language version 1.6 book - Part 7 of 189The Ring programming language version 1.6 book - Part 7 of 189
The Ring programming language version 1.6 book - Part 7 of 189
 
Modern c++
Modern c++Modern c++
Modern c++
 
CDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptorCDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptor
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application Framework
 
Automated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.xAutomated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.x
 
Sandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooksSandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooks
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 

Viewers also liked

Marcodelbuendesempeodocente 3-140901144359-phpapp01
Marcodelbuendesempeodocente 3-140901144359-phpapp01Marcodelbuendesempeodocente 3-140901144359-phpapp01
Marcodelbuendesempeodocente 3-140901144359-phpapp01
Mauro Micky Quispe
 
informacion en la nube
informacion en la nubeinformacion en la nube
informacion en la nube
francito91
 
Truffly Made Catalog-Recipes 2014 (2)
Truffly Made Catalog-Recipes 2014 (2)Truffly Made Catalog-Recipes 2014 (2)
Truffly Made Catalog-Recipes 2014 (2)
Truffly Made
 
Chat , sobre el maltrato animal
Chat , sobre el maltrato  animalChat , sobre el maltrato  animal
Chat , sobre el maltrato animal
Aydee Calachua
 

Viewers also liked (20)

The Ring programming language version 1.2 book - Part 77 of 84
The Ring programming language version 1.2 book - Part 77 of 84The Ring programming language version 1.2 book - Part 77 of 84
The Ring programming language version 1.2 book - Part 77 of 84
 
The Ring programming language version 1.2 book - Part 65 of 84
The Ring programming language version 1.2 book - Part 65 of 84The Ring programming language version 1.2 book - Part 65 of 84
The Ring programming language version 1.2 book - Part 65 of 84
 
Framework
FrameworkFramework
Framework
 
Trabajo de eduardo bautista 01
Trabajo de eduardo bautista  01Trabajo de eduardo bautista  01
Trabajo de eduardo bautista 01
 
Marcodelbuendesempeodocente 3-140901144359-phpapp01
Marcodelbuendesempeodocente 3-140901144359-phpapp01Marcodelbuendesempeodocente 3-140901144359-phpapp01
Marcodelbuendesempeodocente 3-140901144359-phpapp01
 
Currency high lights 20.02.17
Currency high lights 20.02.17Currency high lights 20.02.17
Currency high lights 20.02.17
 
Aaj ka trend 20.02.17
Aaj ka trend 20.02.17Aaj ka trend 20.02.17
Aaj ka trend 20.02.17
 
Concurs regional de creații plastice și literare '15
Concurs regional de creații plastice și literare '15Concurs regional de creații plastice și literare '15
Concurs regional de creații plastice și literare '15
 
Aydeeeee
AydeeeeeAydeeeee
Aydeeeee
 
informacion en la nube
informacion en la nubeinformacion en la nube
informacion en la nube
 
Las7erresdelconsumidorecologico
Las7erresdelconsumidorecologicoLas7erresdelconsumidorecologico
Las7erresdelconsumidorecologico
 
Strata2015
Strata2015Strata2015
Strata2015
 
informacion en la nube
informacion en la nubeinformacion en la nube
informacion en la nube
 
Truffly Made Catalog-Recipes 2014 (2)
Truffly Made Catalog-Recipes 2014 (2)Truffly Made Catalog-Recipes 2014 (2)
Truffly Made Catalog-Recipes 2014 (2)
 
Uasf....
Uasf....Uasf....
Uasf....
 
Sesión 08
Sesión 08Sesión 08
Sesión 08
 
MAB - DO 1 AO 99 (adaptado)
MAB - DO 1 AO 99 (adaptado)MAB - DO 1 AO 99 (adaptado)
MAB - DO 1 AO 99 (adaptado)
 
Juicio
JuicioJuicio
Juicio
 
Sesión 08
Sesión 08Sesión 08
Sesión 08
 
Chat , sobre el maltrato animal
Chat , sobre el maltrato  animalChat , sobre el maltrato  animal
Chat , sobre el maltrato animal
 

Similar to The Ring programming language version 1.2 book - Part 51 of 84

Similar to The Ring programming language version 1.2 book - Part 51 of 84 (20)

The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210
 
The Ring programming language version 1.4 book - Part 19 of 30
The Ring programming language version 1.4 book - Part 19 of 30The Ring programming language version 1.4 book - Part 19 of 30
The Ring programming language version 1.4 book - Part 19 of 30
 
The Ring programming language version 1.3 book - Part 53 of 88
The Ring programming language version 1.3 book - Part 53 of 88The Ring programming language version 1.3 book - Part 53 of 88
The Ring programming language version 1.3 book - Part 53 of 88
 
Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with XgxperfDeveloping and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
 
The Ring programming language version 1.8 book - Part 78 of 202
The Ring programming language version 1.8 book - Part 78 of 202The Ring programming language version 1.8 book - Part 78 of 202
The Ring programming language version 1.8 book - Part 78 of 202
 
The Ring programming language version 1.7 book - Part 76 of 196
The Ring programming language version 1.7 book - Part 76 of 196The Ring programming language version 1.7 book - Part 76 of 196
The Ring programming language version 1.7 book - Part 76 of 196
 
manual
manualmanual
manual
 
manual
manualmanual
manual
 
The Ring programming language version 1.10 book - Part 72 of 212
The Ring programming language version 1.10 book - Part 72 of 212The Ring programming language version 1.10 book - Part 72 of 212
The Ring programming language version 1.10 book - Part 72 of 212
 
Keyword driven testing in qtp
Keyword driven testing in qtpKeyword driven testing in qtp
Keyword driven testing in qtp
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
KDD 2016 Streaming Analytics Tutorial
KDD 2016 Streaming Analytics TutorialKDD 2016 Streaming Analytics Tutorial
KDD 2016 Streaming Analytics Tutorial
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
 
React Native custom components
React Native custom componentsReact Native custom components
React Native custom components
 
GUI JAVA PROG ~hmftj
GUI  JAVA PROG ~hmftjGUI  JAVA PROG ~hmftj
GUI JAVA PROG ~hmftj
 
Getting started with wxWidgets
Getting started with wxWidgets Getting started with wxWidgets
Getting started with wxWidgets
 
Improving app performance with Kotlin Coroutines
Improving app performance with Kotlin CoroutinesImproving app performance with Kotlin Coroutines
Improving app performance with Kotlin Coroutines
 
27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...
 
The Ring programming language version 1.3 book - Part 7 of 88
The Ring programming language version 1.3 book - Part 7 of 88The Ring programming language version 1.3 book - Part 7 of 88
The Ring programming language version 1.3 book - Part 7 of 88
 
AndroidX Google Extended I/O BKK 2018
AndroidX Google Extended I/O BKK 2018 AndroidX Google Extended I/O BKK 2018
AndroidX Google Extended I/O BKK 2018
 

More from Mahmoud Samir Fayed

More from Mahmoud Samir Fayed (20)

The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 212 of 212The Ring programming language version 1.10 book - Part 212 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 211 of 212The Ring programming language version 1.10 book - Part 211 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 210 of 212The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 210 of 212
 
The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 208 of 212The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 208 of 212
 
The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 207 of 212The Ring programming language version 1.10 book - Part 207 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 205 of 212The Ring programming language version 1.10 book - Part 205 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 206 of 212The Ring programming language version 1.10 book - Part 206 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 204 of 212The Ring programming language version 1.10 book - Part 204 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 203 of 212The Ring programming language version 1.10 book - Part 203 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 202 of 212The Ring programming language version 1.10 book - Part 202 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 201 of 212The Ring programming language version 1.10 book - Part 201 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 200 of 212The Ring programming language version 1.10 book - Part 200 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 199 of 212The Ring programming language version 1.10 book - Part 199 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 198 of 212The Ring programming language version 1.10 book - Part 198 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 197 of 212The Ring programming language version 1.10 book - Part 197 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 196 of 212The Ring programming language version 1.10 book - Part 196 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 195 of 212The Ring programming language version 1.10 book - Part 195 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 194 of 212The Ring programming language version 1.10 book - Part 194 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 193 of 212The Ring programming language version 1.10 book - Part 193 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 192 of 212The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 192 of 212
 

Recently uploaded

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Recently uploaded (20)

WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 

The Ring programming language version 1.2 book - Part 51 of 84

  • 1. Ring Documentation, Release 1.2 Table 47.1 – continued from previous page Class Name Methods to use the default Events QTcpServer SetAcceptErrorEvent() SetNewConnectionEvent() QIODevice SetAboutToCloseEvent() SetBytesWrittenEvent() SetReadChannelFinishedEvent() SetReadyReadEvent() QAbstractSocket SetConnectedEvent() SetDisconnectedEvent() SetErrorEvent() SetHostFoundEvent() SetProxyAuthenticationRequiredEvent() SetStateChangedEvent() QTcpSocket SetConnectedEvent() SetDisconnectedEvent() SetErrorEvent() SetHostFoundEvent() SetProxyAuthenticationRequiredEvent() SetStateChangedEvent() SetAboutToCloseEvent() SetBytesWrittenEvent() SetReadChannelFinishedEvent() SetReadyReadEvent() QColorDialog SetColorSelectedEvent() SetCurrentColorChangedEvent() QNetworkAccessManager SetFinishedEvent() QThread SetStartedEvent() SetFinishedEvent() 47.55 Methods to use Events with Events Filter RingQt define a new class called QAllEvents that help you in using Events Filter The next table presents the methods that we have Methods to get parameters Class Name getKeyCode() –> Number QAllEvents getx() –> Number gety() –> Number getglobalx() –> Number getglobaly() –> Number getbutton() –> Number getbuttons() –> Number The next table presents the methods that we have to use events. 47.55. Methods to use Events with Events Filter 480
  • 2. Ring Documentation, Release 1.2 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) 47.56 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 47.56. The Difference between Qt and RingQt 481
  • 3. Ring Documentation, Release 1.2 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 47.57 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. 47.57. RingQt Classes and their Qt Documentation 482
  • 4. CHAPTER FORTYEIGHT BUILDING RINGQT APPLICATIONS FOR MOBILE In this chapter we will learn about Building RingQt Applications for Mobile. 48.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 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 48.2 Update the Android SDK Update the Android SDK to get the API and tools packages required for development 48.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 483
  • 5. Ring Documentation, Release 1.2 • You will find the code in resourcestest.ring You can modify the code then build and run for Desktop or Mobile. 48.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 files during the runtime from the resources to temp. folder Then run the test.ring 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 48.4. Comments about developing for Android using RingQt 484
  • 6. Ring Documentation, Release 1.2 Example: if isandroid() // Android code 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(":/resources/cardsimage") else mypic = new QPixmap("cards.jpg") ok In the previous example, cards.jpg is added to the resources then we write the “cardsimage” as alias for “cards.jpg” 48.4. Comments about developing for Android using RingQt 485
  • 7. CHAPTER FORTYNINE OBJECTS LIBRARY FOR RINGQT APPLICATION In this chapter we will learn about the objects library for RingQt applications. Ring 1.2 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 49.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. 49.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. • The User Can click on the button many times to open many sub windows. • Each Sub Window contains Two buttons. 486
  • 8. Ring Documentation, Release 1.2 • The first button in the sub window change the Main and the Sub Windows Titles. • The second button in the sub window close the Sub Window. load "guilib.ring" new qApp { open_window( :MainWindowController ) exec() } class MainWindowController from WindowsControllerParent oView = new MainWindowView func SubWindowAction Open_window( :SubWindowController ) Last_Window().SetParentObject(self) class MainWindowView from WindowsViewParent win = new qWidget() { SetWindowTitle("Main Window") btnSub = new qPushButton(win) { setText("Sub Window") setClickEvent( Method( :SubWindowAction ) ) } resize(400,400) } class SubWindowController from WindowsControllerParent oView = new SubWindowView func SetMainWindowTitleAction Parent().oView.win.SetWindowTitle("Message from the Sub Window") oView.win.SetWindowTitle("Click Event Done!") class SubWindowView from WindowsViewParent win = new qWidget() { SetWindowTitle("Sub Window") btnMsg = new qPushButton(win) { setText("Set Main Window Title") setClickEvent( Method( :SetMainWindowTitleAction ) ) } btnClose = new qPushButton(win) { Move(200,0) setText("Close") setClickEvent( Method( :CloseAction ) ) } resize(400,400) } The next screen shot after creating three sub windows. 49.2. Example 487
  • 9. Ring Documentation, Release 1.2 The next screen shot after clicking on the button in each sub window. 49.2. Example 488
  • 10. Ring Documentation, Release 1.2 49.3 Objects Library Source Code The library source code is very simple, You can check the source code files • https://github.com/ring-lang/ring/blob/master/extensions/ringqt/objectslib/objects.ring • https://github.com/ring-lang/ring/blob/master/extensions/ringqt/objectslib/subwindows.ring # List of objects (Windows/Forms) $RingQt_ObjectsList = [] # Contains sub lists [object ID , Object] # The Object ID Counter $RingQt_ObjectID = 0 # Variable used for Windows/Forms object name - used for setting events $RingQt_ObjName = "" # The next constants for the Objects List C_RINGQT_OBJECTSLIST_ID = 1 49.3. Objects Library Source Code 489