CHAPTER
FORTYSIX
BUILDING GAMES FOR ANDROID
In this chapter we will learn about Building RingLibSDL Games for Mobile.
So we can create packages (*.apk) for the applications that are developed using Ring Game Engine for 2D Games.
46.1 Download Requirements and Update the Android SDK
• 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
• Update the Android SDK to get the API and tools packages required for development
46.2 Project Folder
Open the project folder : ring/android/ringlibsdl/project
380
Ring Documentation, Release 1.2
You can add the source code (*.ring) and Images/Sound Files to the assets folder.
You will find the Flappy Bird 3000 Game ready for building.
The execution starts from the start.ring file
load "game2.ring"
46.3 Building the project
Move to the ring/android/ringlibsdl/project folder
We can build using the next command (We need to do this for one time only).
ndk-build
Then we can create the package (*.apk) using the next command.
46.3. Building the project 381
Ring Documentation, Release 1.2
ant debug
46.3. Building the project 382
CHAPTER
FORTYSEVEN
DESKTOP AND MOBILE DEVELOPMENT USING RINGQT
In this chapter we will learn how to use the Qt framework classes in our Ring applications to create Desktop and
Mobile Applications.
47.1 The First GUI Application
In this example we will create an application to ask the user about his/her name. When the user type the name in the
textbox then click on “Say Hello” button, the textbox value will be updated by adding “Hello ” to the name.
Load "guilib.ring"
MyApp = New qApp {
win1 = new qWidget() {
setwindowtitle("Hello World")
setGeometry(100,100,370,250)
label1 = new qLabel(win1) {
settext("What is your name ?")
setGeometry(10,20,350,30)
setalignment(Qt_AlignHCenter)
}
btn1 = new qpushbutton(win1) {
setGeometry(10,200,100,30)
settext("Say Hello")
setclickevent("pHello()")
}
btn1 = new qpushbutton(win1) {
setGeometry(150,200,100,30)
settext("Close")
setclickevent("pClose()")
}
lineedit1 = new qlineedit(win1) {
setGeometry(10,100,350,30)
}
show()
}
383
Ring Documentation, Release 1.2
exec()
}
Func pHello
lineedit1.settext( "Hello " + lineedit1.text())
Func pClose
MyApp.quit()
Program Output:
At first we type the name in the textbox
Then we click on the say hello button
47.1. The First GUI Application 384
Ring Documentation, Release 1.2
47.2 Using Layout
The next example is just an upgrade to the previous application to use the vertical layout.
Load "guilib.ring"
MyApp = New qApp {
win1 = new qWidget() {
setwindowtitle("Hello World")
setGeometry(100,100,400,130)
label1 = new qLabel(win1) {
settext("What is your name ?")
setGeometry(10,20,350,30)
setalignment(Qt_AlignHCenter)
}
btn1 = new qpushbutton(win1) {
setGeometry(10,200,100,30)
settext("Say Hello")
setclickevent("pHello()")
}
btn2 = new qpushbutton(win1) {
setGeometry(150,200,100,30)
settext("Close")
setclickevent("pClose()")
}
lineedit1 = new qlineedit(win1) {
setGeometry(10,100,350,30)
}
layout1 = new qVBoxLayout() {
addwidget(label1)
addwidget(lineedit1)
addwidget(btn1)
addwidget(btn2)
}
win1.setlayout(layout1)
show()
}
exec()
}
Func pHello
lineedit1.settext( "Hello " + lineedit1.text())
Func pClose
MyApp.quit()
The application during the runtime!
47.2. Using Layout 385
Ring Documentation, Release 1.2
47.3 Using the QTextEdit Class
In this example we will use the QTextEdit Class
Load "guilib.ring"
New qApp {
win1 = new qWidget() {
setwindowtitle("QTextEdit Class")
setGeometry(100,100,500,500)
new qtextedit(win1) {
setGeometry(10,10,480,480)
}
show()
}
exec()
}
During the runtime we can paste rich text in the qtextedit widget
47.3. Using the QTextEdit Class 386
Ring Documentation, Release 1.2
47.4 Using the QListWidget Class
In this example we will use the QListWidget Class
Load "guilib.ring"
New qApp {
win1 = new qWidget() {
setGeometry(100,100,400,400)
list1 = new qlistwidget(win1) {
setGeometry(150,100,200,200)
alist = ["one","two","three","four","five"]
for x in alist additem(x) next
setcurrentrow(3,2)
win1.setwindowtitle("Items Count : " + count() )
}
47.4. Using the QListWidget Class 387
Ring Documentation, Release 1.2
btn1 = new qpushbutton(win1) {
setGeometry(10,200,100,30)
settext("selected item")
setclickevent("pWork()")
}
btn2 = new qpushbutton(win1) {
setGeometry(10,240,100,30)
settext("Delete item")
setclickevent("pWork2()")
}
show()
}
exec()
}
func pWork
btn1.settext(string(list1.currentrow()))
func pWork2
list1 {
takeitem(currentrow())
}
The application during the runtime
47.4. Using the QListWidget Class 388
Ring Documentation, Release 1.2
Another Example:
Load "guilib.ring"
New qApp {
win1 = new qWidget() {
setGeometry(100,100,500,400)
list1 = new qlistwidget(win1) {
setGeometry(150,100,200,200)
alist = ["one","two","three","four","five"]
for x in alist additem(x) next
setcurrentrow(3,2)
win1.setwindowtitle("Items Count : " + count() )
}
btn1 = new qpushbutton(win1) {
setGeometry(10,200,100,30)
settext("selected item")
setclickevent("pWork()")
}
btn2 = new qpushbutton(win1) {
setGeometry(10,240,100,30)
settext("Delete item")
setclickevent("pWork2()")
}
show()
}
exec()
}
func pWork
nbrOfItems = list1.count()
curItemNbr = list1.currentrow()
curValue = list1.item(list1.currentrow()).text()
win1.setwindowtitle( "After Select - NbrOfItems: " + nbrOfItems +
" CurItemNbr: " + curItemNbr + " CurValue: " + curValue )
btn1.settext( string(list1.currentrow() ) + " --- " +
list1.item(list1.currentrow()).text() )
func pWork2
list1 {
takeitem(currentrow())
nbrOfItems = count()
curItemNbr = currentrow()
curValue = item(currentrow()).text()
47.4. Using the QListWidget Class 389

More Related Content

PDF
The Ring programming language version 1.2 book - Part 46 of 84
PDF
The Ring programming language version 1.2 book - Part 48 of 84
PDF
The Ring programming language version 1.2 book - Part 49 of 84
PDF
The Ring programming language version 1.2 book - Part 47 of 84
PDF
The Ring programming language version 1.5.4 book - Part 68 of 185
PDF
The Ring programming language version 1.9 book - Part 78 of 210
PDF
The Ring programming language version 1.3 book - Part 46 of 88
PDF
The Ring programming language version 1.10 book - Part 79 of 212
The Ring programming language version 1.2 book - Part 46 of 84
The Ring programming language version 1.2 book - Part 48 of 84
The Ring programming language version 1.2 book - Part 49 of 84
The Ring programming language version 1.2 book - Part 47 of 84
The Ring programming language version 1.5.4 book - Part 68 of 185
The Ring programming language version 1.9 book - Part 78 of 210
The Ring programming language version 1.3 book - Part 46 of 88
The Ring programming language version 1.10 book - Part 79 of 212

What's hot (20)

PDF
The Ring programming language version 1.4 book - Part 17 of 30
PDF
The Ring programming language version 1.5.4 book - Part 67 of 185
PDF
The Ring programming language version 1.3 book - Part 47 of 88
PDF
The Ring programming language version 1.7 book - Part 72 of 196
PDF
The Ring programming language version 1.6 book - Part 69 of 189
PDF
The Ring programming language version 1.5 book - Part 11 of 31
PDF
The Ring programming language version 1.5.2 book - Part 62 of 181
PDF
The Ring programming language version 1.5.2 book - Part 64 of 181
PDF
The Ring programming language version 1.5.1 book - Part 63 of 180
PDF
The Ring programming language version 1.8 book - Part 71 of 202
PDF
The Ring programming language version 1.8 book - Part 74 of 202
PDF
The Ring programming language version 1.8 book - Part 67 of 202
PDF
The Ring programming language version 1.4 book - Part 16 of 30
PDF
The Ring programming language version 1.5.3 book - Part 74 of 184
PDF
The Ring programming language version 1.9 book - Part 75 of 210
PDF
The Ring programming language version 1.7 book - Part 67 of 196
PDF
The Ring programming language version 1.5.1 book - Part 64 of 180
PDF
The Ring programming language version 1.10 book - Part 76 of 212
PDF
The Ring programming language version 1.9 book - Part 76 of 210
PDF
The Ring programming language version 1.10 book - Part 74 of 212
The Ring programming language version 1.4 book - Part 17 of 30
The Ring programming language version 1.5.4 book - Part 67 of 185
The Ring programming language version 1.3 book - Part 47 of 88
The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.5 book - Part 11 of 31
The Ring programming language version 1.5.2 book - Part 62 of 181
The Ring programming language version 1.5.2 book - Part 64 of 181
The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.8 book - Part 71 of 202
The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 67 of 202
The Ring programming language version 1.4 book - Part 16 of 30
The Ring programming language version 1.5.3 book - Part 74 of 184
The Ring programming language version 1.9 book - Part 75 of 210
The Ring programming language version 1.7 book - Part 67 of 196
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.10 book - Part 76 of 212
The Ring programming language version 1.9 book - Part 76 of 210
The Ring programming language version 1.10 book - Part 74 of 212

Viewers also liked (17)

PDF
The Ring programming language version 1.2 book - Part 5 of 84
PDF
The Ring programming language version 1.2 book - Part 2 of 84
PDF
The Ring programming language version 1.2 book - Part 4 of 84
PPTX
Windows 10 Technical Support
PDF
The Ring programming language version 1.2 book - Part 43 of 84
PPT
робота над проектом, 5 клас
PPTX
Trade barriers
DOCX
Unidad 4
PPTX
Question 2 V2
PPTX
3Com NB TR RA 449
PPTX
Презентація на тему"Шкода чи користь від шоколаду"
PDF
VIJAYA OOHMEDIA SOLUTIONS PVT LTD
PDF
Gromadske slovo (18.02.2017)
PDF
The Ring programming language version 1.2 book - Part 39 of 84
PPTX
презентация дошкільного підрозділу Ладижинського НВК №1
PPTX
4° A ofimatica ivett
PPT
Radionica 1 školski list u funkciji razvijanja kompetencija ucenika - primer ...
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 2 of 84
The Ring programming language version 1.2 book - Part 4 of 84
Windows 10 Technical Support
The Ring programming language version 1.2 book - Part 43 of 84
робота над проектом, 5 клас
Trade barriers
Unidad 4
Question 2 V2
3Com NB TR RA 449
Презентація на тему"Шкода чи користь від шоколаду"
VIJAYA OOHMEDIA SOLUTIONS PVT LTD
Gromadske slovo (18.02.2017)
The Ring programming language version 1.2 book - Part 39 of 84
презентация дошкільного підрозділу Ладижинського НВК №1
4° A ofimatica ivett
Radionica 1 školski list u funkciji razvijanja kompetencija ucenika - primer ...

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

PDF
The Ring programming language version 1.4.1 book - Part 16 of 31
PDF
The Ring programming language version 1.5.3 book - Part 70 of 184
PDF
The Ring programming language version 1.10 book - Part 72 of 212
PDF
The Ring programming language version 1.3 book - Part 43 of 88
PDF
The Ring programming language version 1.7 book - Part 65 of 196
PDF
The Ring programming language version 1.6 book - Part 63 of 189
PDF
The Ring programming language version 1.5.2 book - Part 58 of 181
PDF
The Ring programming language version 1.5.1 book - Part 57 of 180
PDF
The Ring programming language version 1.2 book - Part 51 of 84
PDF
The Ring programming language version 1.9 book - Part 71 of 210
PDF
The Ring programming language version 1.3 book - Part 52 of 88
PDF
The Ring programming language version 1.9 book - Part 80 of 210
PDF
The Ring programming language version 1.2 book - Part 50 of 84
PDF
The Ring programming language version 1.3 book - Part 44 of 88
PDF
The Ring programming language version 1.3 book - Part 45 of 88
PDF
The Ring programming language version 1.5.2 book - Part 60 of 181
PDF
The Ring programming language version 1.9 book - Part 81 of 210
PDF
The Ring programming language version 1.5.3 book - Part 79 of 184
PDF
The Ring programming language version 1.2 book - Part 82 of 84
PDF
The Ring programming language version 1.7 book - Part 74 of 196
The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.5.3 book - Part 70 of 184
The Ring programming language version 1.10 book - Part 72 of 212
The Ring programming language version 1.3 book - Part 43 of 88
The Ring programming language version 1.7 book - Part 65 of 196
The Ring programming language version 1.6 book - Part 63 of 189
The Ring programming language version 1.5.2 book - Part 58 of 181
The Ring programming language version 1.5.1 book - Part 57 of 180
The Ring programming language version 1.2 book - Part 51 of 84
The Ring programming language version 1.9 book - Part 71 of 210
The Ring programming language version 1.3 book - Part 52 of 88
The Ring programming language version 1.9 book - Part 80 of 210
The Ring programming language version 1.2 book - Part 50 of 84
The Ring programming language version 1.3 book - Part 44 of 88
The Ring programming language version 1.3 book - Part 45 of 88
The Ring programming language version 1.5.2 book - Part 60 of 181
The Ring programming language version 1.9 book - Part 81 of 210
The Ring programming language version 1.5.3 book - Part 79 of 184
The Ring programming language version 1.2 book - Part 82 of 84
The Ring programming language version 1.7 book - Part 74 of 196

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 208 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
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 208 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

Recently uploaded (20)

PDF
How to Write Automated Test Scripts Using Selenium.pdf
PDF
C language slides for c programming book by ANSI
PPTX
Greedy best-first search algorithm always selects the path which appears best...
PDF
IDM Crack Activation Key 2025 Free Download
PPTX
Streamlining Project Management in the AV Industry with D-Tools for Zoho CRM ...
PPTX
Improving Audience Engagement ROI with ERP-Powered Insights
PPTX
SAP Business AI_L1 Overview_EXTERNAL.pptx
PDF
How to Set Realistic Project Milestones and Deadlines
PDF
OpenAssetIO Virtual Town Hall - August 2025.pdf
PPTX
StacksandQueuesCLASS 12 COMPUTER SCIENCE.pptx
PPTX
Advanced Heap Dump Analysis Techniques Webinar Deck
PPTX
Why 2025 Is the Best Year to Hire Software Developers in India
PDF
DOWNLOAD—IOBit Uninstaller Pro Crack Download Free
PPTX
Comprehensive Guide to Digital Image Processing Concepts and Applications
PDF
Ragic Data Security Overview: Certifications, Compliance, and Network Safegua...
PDF
solman-7.0-ehp1-sp21-incident-management
PDF
SBOM Document Quality Guide - OpenChain SBOM Study Group
PDF
Difference Between Website and Web Application.pdf
PDF
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
PPTX
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
How to Write Automated Test Scripts Using Selenium.pdf
C language slides for c programming book by ANSI
Greedy best-first search algorithm always selects the path which appears best...
IDM Crack Activation Key 2025 Free Download
Streamlining Project Management in the AV Industry with D-Tools for Zoho CRM ...
Improving Audience Engagement ROI with ERP-Powered Insights
SAP Business AI_L1 Overview_EXTERNAL.pptx
How to Set Realistic Project Milestones and Deadlines
OpenAssetIO Virtual Town Hall - August 2025.pdf
StacksandQueuesCLASS 12 COMPUTER SCIENCE.pptx
Advanced Heap Dump Analysis Techniques Webinar Deck
Why 2025 Is the Best Year to Hire Software Developers in India
DOWNLOAD—IOBit Uninstaller Pro Crack Download Free
Comprehensive Guide to Digital Image Processing Concepts and Applications
Ragic Data Security Overview: Certifications, Compliance, and Network Safegua...
solman-7.0-ehp1-sp21-incident-management
SBOM Document Quality Guide - OpenChain SBOM Study Group
Difference Between Website and Web Application.pdf
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB

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

  • 1. CHAPTER FORTYSIX BUILDING GAMES FOR ANDROID In this chapter we will learn about Building RingLibSDL Games for Mobile. So we can create packages (*.apk) for the applications that are developed using Ring Game Engine for 2D Games. 46.1 Download Requirements and Update the Android SDK • 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 • Update the Android SDK to get the API and tools packages required for development 46.2 Project Folder Open the project folder : ring/android/ringlibsdl/project 380
  • 2. Ring Documentation, Release 1.2 You can add the source code (*.ring) and Images/Sound Files to the assets folder. You will find the Flappy Bird 3000 Game ready for building. The execution starts from the start.ring file load "game2.ring" 46.3 Building the project Move to the ring/android/ringlibsdl/project folder We can build using the next command (We need to do this for one time only). ndk-build Then we can create the package (*.apk) using the next command. 46.3. Building the project 381
  • 3. Ring Documentation, Release 1.2 ant debug 46.3. Building the project 382
  • 4. CHAPTER FORTYSEVEN DESKTOP AND MOBILE DEVELOPMENT USING RINGQT In this chapter we will learn how to use the Qt framework classes in our Ring applications to create Desktop and Mobile Applications. 47.1 The First GUI Application In this example we will create an application to ask the user about his/her name. When the user type the name in the textbox then click on “Say Hello” button, the textbox value will be updated by adding “Hello ” to the name. Load "guilib.ring" MyApp = New qApp { win1 = new qWidget() { setwindowtitle("Hello World") setGeometry(100,100,370,250) label1 = new qLabel(win1) { settext("What is your name ?") setGeometry(10,20,350,30) setalignment(Qt_AlignHCenter) } btn1 = new qpushbutton(win1) { setGeometry(10,200,100,30) settext("Say Hello") setclickevent("pHello()") } btn1 = new qpushbutton(win1) { setGeometry(150,200,100,30) settext("Close") setclickevent("pClose()") } lineedit1 = new qlineedit(win1) { setGeometry(10,100,350,30) } show() } 383
  • 5. Ring Documentation, Release 1.2 exec() } Func pHello lineedit1.settext( "Hello " + lineedit1.text()) Func pClose MyApp.quit() Program Output: At first we type the name in the textbox Then we click on the say hello button 47.1. The First GUI Application 384
  • 6. Ring Documentation, Release 1.2 47.2 Using Layout The next example is just an upgrade to the previous application to use the vertical layout. Load "guilib.ring" MyApp = New qApp { win1 = new qWidget() { setwindowtitle("Hello World") setGeometry(100,100,400,130) label1 = new qLabel(win1) { settext("What is your name ?") setGeometry(10,20,350,30) setalignment(Qt_AlignHCenter) } btn1 = new qpushbutton(win1) { setGeometry(10,200,100,30) settext("Say Hello") setclickevent("pHello()") } btn2 = new qpushbutton(win1) { setGeometry(150,200,100,30) settext("Close") setclickevent("pClose()") } lineedit1 = new qlineedit(win1) { setGeometry(10,100,350,30) } layout1 = new qVBoxLayout() { addwidget(label1) addwidget(lineedit1) addwidget(btn1) addwidget(btn2) } win1.setlayout(layout1) show() } exec() } Func pHello lineedit1.settext( "Hello " + lineedit1.text()) Func pClose MyApp.quit() The application during the runtime! 47.2. Using Layout 385
  • 7. Ring Documentation, Release 1.2 47.3 Using the QTextEdit Class In this example we will use the QTextEdit Class Load "guilib.ring" New qApp { win1 = new qWidget() { setwindowtitle("QTextEdit Class") setGeometry(100,100,500,500) new qtextedit(win1) { setGeometry(10,10,480,480) } show() } exec() } During the runtime we can paste rich text in the qtextedit widget 47.3. Using the QTextEdit Class 386
  • 8. Ring Documentation, Release 1.2 47.4 Using the QListWidget Class In this example we will use the QListWidget Class Load "guilib.ring" New qApp { win1 = new qWidget() { setGeometry(100,100,400,400) list1 = new qlistwidget(win1) { setGeometry(150,100,200,200) alist = ["one","two","three","four","five"] for x in alist additem(x) next setcurrentrow(3,2) win1.setwindowtitle("Items Count : " + count() ) } 47.4. Using the QListWidget Class 387
  • 9. Ring Documentation, Release 1.2 btn1 = new qpushbutton(win1) { setGeometry(10,200,100,30) settext("selected item") setclickevent("pWork()") } btn2 = new qpushbutton(win1) { setGeometry(10,240,100,30) settext("Delete item") setclickevent("pWork2()") } show() } exec() } func pWork btn1.settext(string(list1.currentrow())) func pWork2 list1 { takeitem(currentrow()) } The application during the runtime 47.4. Using the QListWidget Class 388
  • 10. Ring Documentation, Release 1.2 Another Example: Load "guilib.ring" New qApp { win1 = new qWidget() { setGeometry(100,100,500,400) list1 = new qlistwidget(win1) { setGeometry(150,100,200,200) alist = ["one","two","three","four","five"] for x in alist additem(x) next setcurrentrow(3,2) win1.setwindowtitle("Items Count : " + count() ) } btn1 = new qpushbutton(win1) { setGeometry(10,200,100,30) settext("selected item") setclickevent("pWork()") } btn2 = new qpushbutton(win1) { setGeometry(10,240,100,30) settext("Delete item") setclickevent("pWork2()") } show() } exec() } func pWork nbrOfItems = list1.count() curItemNbr = list1.currentrow() curValue = list1.item(list1.currentrow()).text() win1.setwindowtitle( "After Select - NbrOfItems: " + nbrOfItems + " CurItemNbr: " + curItemNbr + " CurValue: " + curValue ) btn1.settext( string(list1.currentrow() ) + " --- " + list1.item(list1.currentrow()).text() ) func pWork2 list1 { takeitem(currentrow()) nbrOfItems = count() curItemNbr = currentrow() curValue = item(currentrow()).text() 47.4. Using the QListWidget Class 389