SlideShare a Scribd company logo
Ring Documentation, Release 1.9
64.38 Creating More than one Window
The next example demonstrates how to create more than one window
Load "guilib.ring"
app1 = new qapp {
win1 = new qwidget() {
64.38. Creating More than one Window 719
Ring Documentation, Release 1.9
setwindowtitle("First")
setgeometry(100,100,500,500)
new qpushbutton(win1) {
setgeometry(100,100,100,30)
settext("close")
setclickevent("app1.quit()")
}
new qpushbutton(win1) {
setgeometry(250,100,100,30)
settext("Second")
setclickevent("second()")
}
showmaximized()
}
exec()
}
func second
win2 = new qwidget() {
setwindowtitle("Second")
setgeometry(100,100,500,500)
setwindowflags(Qt_dialog)
show()
}
The application during the runtime
64.39 Playing Sound
Example:
64.39. Playing Sound 720
Ring Documentation, Release 1.9
Load "guilib.ring"
new qapp {
win1 = new qwidget() {
setwindowtitle("play sound!") show()
}
new qmediaplayer() {
setmedia(new qurl("footstep.wav"))
setvolume(50) play()
}
exec()
}
64.40 Using the QColorDialog Class
Example:
Load "guilib.ring"
oApp = new myapp { start() }
Class MyApp
oColor win1
Func start
myapp = new qapp
win1 = new qMainWindow() {
setwindowtitle("Color Dialog")
setgeometry(100,100,400,400)
}
new qpushbutton(win1) {
setgeometry(10,10,100,30)
settext("Get Color")
setclickevent("oApp.pColor()")
}
win1.show()
myapp.exec()
Func pColor
myobj = new qcolordialog()
aColor = myobj.GetColor()
r=acolor[1] g=acolor[2] b=acolor[3]
win1.setstylesheet("background-color: rgb("+r+", " + g+ "," + b + ")")
The application during the runtime
64.40. Using the QColorDialog Class 721
Ring Documentation, Release 1.9
64.41 Using qLCDNumber Class
In this example we will learn about using the qLCDNumber class
Load "guilib.ring"
New qApp
{
win1 = new qWidget()
{
setwindowtitle("LCD Number")
setgeometry(100,100,250,120)
new qLCDNumber(win1)
{
setgeometry(10,10,100,40)
display(100)
}
new qLCDNumber(win1)
{
setgeometry(10,60,100,40)
display(80)
}
show()
}
exec()
}
64.41. Using qLCDNumber Class 722
Ring Documentation, Release 1.9
The application during the runtime
64.42 Movable Label Example
Load "guilib.ring"
new qApp {
win1 = new qWidget()
{
label1 = new qLabel(win1)
{
setText("Welcome")
setgeometry(10,10,200,50)
setstylesheet("color: purple ; font-size: 30pt;")
}
new qTimer(win1)
{
setInterVal(10)
setTimeOutEvent("pMove()")
start()
}
setWindowTitle("Movable Label")
setgeometry(100,100,600,80)
setStyleSheet("background-color: white;")
show()
}
exec()
}
Func pMove
label1
{
move(x()+1,y())
if x() > 600
move(10,y())
ok
}
The application during the runtime
64.42. Movable Label Example 723
Ring Documentation, Release 1.9
64.43 QMessagebox Example
In this section we will learn how to check the output of the Message box
Load "guilib.ring"
new qApp {
win1 = new qWidget()
{
label1 = new qpushbutton(win1)
{
setText("Test")
setgeometry(10,10,200,50)
setstylesheet("color: purple ; font-size: 30pt;")
setclickevent("pWork()")
}
setWindowTitle("Messagebox")
setgeometry(100,100,600,80)
setStyleSheet("background-color: white;")
show()
}
exec()
}
func pWork
new qmessagebox(win1)
{
setwindowtitle("messagebox title")
settext("messagebox text")
setInformativeText("Do you want to save your changes?")
setstandardbuttons(QMessageBox_Yes | QMessageBox_No | QMessageBox_Close)
result = exec()
win1 {
if result = QMessageBox_Yes
setwindowtitle("Yes")
but result = QMessageBox_No
setwindowtitle("No")
but result = QMessageBox_Close
setwindowtitle("Close")
ok
}
}
The application during the runtime
64.43. QMessagebox Example 724
Ring Documentation, Release 1.9
64.44 Using QInputDialog Class
In the next example we will learn about using the QInputDialog class
Load "guilib.ring"
New QApp {
Win1 = New QWidget () {
SetGeometry(100,100,400,400)
SetWindowTitle("Input Dialog")
New QPushButton(win1)
{
SetText ("Input Dialog")
SetGeometry(100,100,100,30)
SetClickEvent("pWork()")
}
Show()
}
exec()
}
Func pWork
oInput = New QInputDialog(win1)
{
setwindowtitle("What is your name?")
setgeometry(100,100,400,50)
setlabeltext("User Name")
settextvalue("Mahmoud")
lcheck = exec()
64.44. Using QInputDialog Class 725
Ring Documentation, Release 1.9
if lCheck win1.setwindowtitle(oInput.textvalue()) ok
}
The application during the runtime
64.45 Dialog Functions
We have the next functions
SetDialogIcon(cIconFile)
MsgInfo(cTitle,cMessage)
ConfirmMsg(cTitle,cMessage) --> lResult
InputBox(cTitle,cMessage) --> cValue
InputBoxInt(cTitle,cMessage) --> nValue
InputBoxNum(cTitle,cMessage) --> nValue
InputBoxPass(cTitle,cMessage) --> cValue
Example
load "guilib.ring"
new qApp
{
SetDialogIcon("notepad.png")
msginfo(:Ring,:Welcome)
see confirmMsg(:Ring,"Are you sure?") + nl
64.45. Dialog Functions 726
Ring Documentation, Release 1.9
see InputBoxNum(:Ring,"Enter Number(double) :") + nl
see InputBox(:Ring,"Enter Value :") + nl
see InputBoxInt(:Ring,"Enter Number(int)") + nl
see InputBoxPass(:Ring,"Enter Password") +nl
}
64.46 KeyPress and Mouse Move Events
In this example we will learn how to use the Events Filter to know about KeyPress and Mouse Move Events
Load "guilib.ring"
new qApp {
win1 = new qWidget()
{
setWindowTitle("Test using Event Filter!")
setGeometry(100,100,400,400)
setmousetracking(true)
myfilter = new qallevents(win1)
myfilter.setKeyPressEvent("pWork()")
myfilter.setMouseButtonPressevent("pClick()")
myfilter.setmousemoveevent("pMove()")
installeventfilter(myfilter)
show()
}
exec()
}
func pWork
win1.setwindowtitle('KeyPress! : ' + myfilter.getkeycode())
func pClick
new qmessagebox(win1) {
setgeometry(100,100,400,100)
setwindowtitle("click event!")
settext("x : " + myfilter.getx() +
" y : " + myfilter.gety() + " button : " +
myfilter.getbutton() )
show()
}
func pMove
win1.setwindowtitle("Mouse Move , X : " + myfilter.getx() +
" Y : " + myfilter.gety() )
The application during the runtime
64.46. KeyPress and Mouse Move Events 727
Ring Documentation, Release 1.9
64.47 Moving Objects using the Mouse
In the next example we will learn how to program movable objects where the user can move a label
Load "guilib.ring"
lPress = false
nX = 0
nY = 0
new qApp {
win1 = new qWidget()
{
setWindowTitle("Move this label!")
setGeometry(100,100,400,400)
setstylesheet("background-color:white;")
Label1 = new qLabel(Win1){
setGeometry(100,100,200,50)
setText("Welcome")
setstylesheet("font-size: 30pt")
myfilter = new qallevents(label1)
myfilter.setEnterevent("pEnter()")
myfilter.setLeaveevent("pLeave()")
64.47. Moving Objects using the Mouse 728

More Related Content

PDF
The Ring programming language version 1.5.2 book - Part 62 of 181
PDF
The Ring programming language version 1.10 book - Part 75 of 212
PDF
The Ring programming language version 1.7 book - Part 67 of 196
PDF
The Ring programming language version 1.2 book - Part 44 of 84
PDF
The Ring programming language version 1.5.3 book - Part 72 of 184
PDF
The Ring programming language version 1.8 book - Part 69 of 202
PDF
The Ring programming language version 1.3 book - Part 45 of 88
PDF
The Ring programming language version 1.5.3 book - Part 73 of 184
The Ring programming language version 1.5.2 book - Part 62 of 181
The Ring programming language version 1.10 book - Part 75 of 212
The Ring programming language version 1.7 book - Part 67 of 196
The Ring programming language version 1.2 book - Part 44 of 84
The Ring programming language version 1.5.3 book - Part 72 of 184
The Ring programming language version 1.8 book - Part 69 of 202
The Ring programming language version 1.3 book - Part 45 of 88
The Ring programming language version 1.5.3 book - Part 73 of 184

What's hot (20)

PDF
The Ring programming language version 1.5.4 book - Part 63 of 185
PDF
The Ring programming language version 1.2 book - Part 41 of 84
PDF
The Ring programming language version 1.5.1 book - Part 58 of 180
PDF
The Ring programming language version 1.2 book - Part 43 of 84
PDF
The Ring programming language version 1.5.2 book - Part 60 of 181
PDF
The Ring programming language version 1.10 book - Part 74 of 212
PDF
The Ring programming language version 1.6 book - Part 65 of 189
PDF
The Ring programming language version 1.4.1 book - Part 16 of 31
PDF
The Ring programming language version 1.3 book - Part 49 of 88
PDF
The Ring programming language version 1.8 book - Part 72 of 202
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.9 book - Part 74 of 210
PDF
The Ring programming language version 1.5.2 book - Part 59 of 181
PDF
The Ring programming language version 1.7 book - Part 65 of 196
PDF
The Ring programming language version 1.10 book - Part 77 of 212
PDF
The Ring programming language version 1.5.3 book - Part 76 of 184
PDF
The Ring programming language version 1.7 book - Part 69 of 196
PDF
The Ring programming language version 1.8 book - Part 67 of 202
PDF
The Ring programming language version 1.2 book - Part 49 of 84
The Ring programming language version 1.5.4 book - Part 63 of 185
The Ring programming language version 1.2 book - Part 41 of 84
The Ring programming language version 1.5.1 book - Part 58 of 180
The Ring programming language version 1.2 book - Part 43 of 84
The Ring programming language version 1.5.2 book - Part 60 of 181
The Ring programming language version 1.10 book - Part 74 of 212
The Ring programming language version 1.6 book - Part 65 of 189
The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.3 book - Part 49 of 88
The Ring programming language version 1.8 book - Part 72 of 202
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.9 book - Part 74 of 210
The Ring programming language version 1.5.2 book - Part 59 of 181
The Ring programming language version 1.7 book - Part 65 of 196
The Ring programming language version 1.10 book - Part 77 of 212
The Ring programming language version 1.5.3 book - Part 76 of 184
The Ring programming language version 1.7 book - Part 69 of 196
The Ring programming language version 1.8 book - Part 67 of 202
The Ring programming language version 1.2 book - Part 49 of 84
Ad

Similar to The Ring programming language version 1.9 book - Part 76 of 210 (20)

PDF
The Ring programming language version 1.5.2 book - Part 61 of 181
PDF
The Ring programming language version 1.7 book - Part 70 of 196
PDF
The Ring programming language version 1.4.1 book - Part 17 of 31
PDF
The Ring programming language version 1.5.1 book - Part 60 of 180
PDF
The Ring programming language version 1.6 book - Part 66 of 189
PDF
The Ring programming language version 1.10 book - Part 73 of 212
PDF
The Ring programming language version 1.7 book - Part 66 of 196
PDF
The Ring programming language version 1.7 book - Part 68 of 196
PDF
The Ring programming language version 1.9 book - Part 72 of 210
PDF
The Ring programming language version 1.8 book - Part 70 of 202
PDF
The Ring programming language version 1.9 book - Part 71 of 210
PDF
The Ring programming language version 1.5 book - Part 11 of 31
PDF
The Ring programming language version 1.5.4 book - Part 64 of 185
PDF
The Ring programming language version 1.5.2 book - Part 63 of 181
PDF
The Ring programming language version 1.10 book - Part 83 of 212
PDF
The Ring programming language version 1.5.3 book - Part 81 of 184
PDF
The Ring programming language version 1.4 book - Part 17 of 30
PDF
The Ring programming language version 1.10 book - Part 72 of 212
PDF
The Ring programming language version 1.9 book - Part 73 of 210
PDF
The Ring programming language version 1.8 book - Part 68 of 202
The Ring programming language version 1.5.2 book - Part 61 of 181
The Ring programming language version 1.7 book - Part 70 of 196
The Ring programming language version 1.4.1 book - Part 17 of 31
The Ring programming language version 1.5.1 book - Part 60 of 180
The Ring programming language version 1.6 book - Part 66 of 189
The Ring programming language version 1.10 book - Part 73 of 212
The Ring programming language version 1.7 book - Part 66 of 196
The Ring programming language version 1.7 book - Part 68 of 196
The Ring programming language version 1.9 book - Part 72 of 210
The Ring programming language version 1.8 book - Part 70 of 202
The Ring programming language version 1.9 book - Part 71 of 210
The Ring programming language version 1.5 book - Part 11 of 31
The Ring programming language version 1.5.4 book - Part 64 of 185
The Ring programming language version 1.5.2 book - Part 63 of 181
The Ring programming language version 1.10 book - Part 83 of 212
The Ring programming language version 1.5.3 book - Part 81 of 184
The Ring programming language version 1.4 book - Part 17 of 30
The Ring programming language version 1.10 book - Part 72 of 212
The Ring programming language version 1.9 book - Part 73 of 210
The Ring programming language version 1.8 book - Part 68 of 202
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 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
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
System and Network Administration Chapter 2
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
AI in Product Development-omnex systems
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
history of c programming in notes for students .pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
ai tools demonstartion for schools and inter college
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Essential Infomation Tech presentation.pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
System and Network Administration Chapter 2
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Understanding Forklifts - TECH EHS Solution
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
AI in Product Development-omnex systems
Design an Analysis of Algorithms II-SECS-1021-03
Reimagine Home Health with the Power of Agentic AI​
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
history of c programming in notes for students .pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
ai tools demonstartion for schools and inter college
Odoo POS Development Services by CandidRoot Solutions
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Essential Infomation Tech presentation.pptx
Odoo Companies in India – Driving Business Transformation.pdf

The Ring programming language version 1.9 book - Part 76 of 210

  • 1. Ring Documentation, Release 1.9 64.38 Creating More than one Window The next example demonstrates how to create more than one window Load "guilib.ring" app1 = new qapp { win1 = new qwidget() { 64.38. Creating More than one Window 719
  • 2. Ring Documentation, Release 1.9 setwindowtitle("First") setgeometry(100,100,500,500) new qpushbutton(win1) { setgeometry(100,100,100,30) settext("close") setclickevent("app1.quit()") } new qpushbutton(win1) { setgeometry(250,100,100,30) settext("Second") setclickevent("second()") } showmaximized() } exec() } func second win2 = new qwidget() { setwindowtitle("Second") setgeometry(100,100,500,500) setwindowflags(Qt_dialog) show() } The application during the runtime 64.39 Playing Sound Example: 64.39. Playing Sound 720
  • 3. Ring Documentation, Release 1.9 Load "guilib.ring" new qapp { win1 = new qwidget() { setwindowtitle("play sound!") show() } new qmediaplayer() { setmedia(new qurl("footstep.wav")) setvolume(50) play() } exec() } 64.40 Using the QColorDialog Class Example: Load "guilib.ring" oApp = new myapp { start() } Class MyApp oColor win1 Func start myapp = new qapp win1 = new qMainWindow() { setwindowtitle("Color Dialog") setgeometry(100,100,400,400) } new qpushbutton(win1) { setgeometry(10,10,100,30) settext("Get Color") setclickevent("oApp.pColor()") } win1.show() myapp.exec() Func pColor myobj = new qcolordialog() aColor = myobj.GetColor() r=acolor[1] g=acolor[2] b=acolor[3] win1.setstylesheet("background-color: rgb("+r+", " + g+ "," + b + ")") The application during the runtime 64.40. Using the QColorDialog Class 721
  • 4. Ring Documentation, Release 1.9 64.41 Using qLCDNumber Class In this example we will learn about using the qLCDNumber class Load "guilib.ring" New qApp { win1 = new qWidget() { setwindowtitle("LCD Number") setgeometry(100,100,250,120) new qLCDNumber(win1) { setgeometry(10,10,100,40) display(100) } new qLCDNumber(win1) { setgeometry(10,60,100,40) display(80) } show() } exec() } 64.41. Using qLCDNumber Class 722
  • 5. Ring Documentation, Release 1.9 The application during the runtime 64.42 Movable Label Example Load "guilib.ring" new qApp { win1 = new qWidget() { label1 = new qLabel(win1) { setText("Welcome") setgeometry(10,10,200,50) setstylesheet("color: purple ; font-size: 30pt;") } new qTimer(win1) { setInterVal(10) setTimeOutEvent("pMove()") start() } setWindowTitle("Movable Label") setgeometry(100,100,600,80) setStyleSheet("background-color: white;") show() } exec() } Func pMove label1 { move(x()+1,y()) if x() > 600 move(10,y()) ok } The application during the runtime 64.42. Movable Label Example 723
  • 6. Ring Documentation, Release 1.9 64.43 QMessagebox Example In this section we will learn how to check the output of the Message box Load "guilib.ring" new qApp { win1 = new qWidget() { label1 = new qpushbutton(win1) { setText("Test") setgeometry(10,10,200,50) setstylesheet("color: purple ; font-size: 30pt;") setclickevent("pWork()") } setWindowTitle("Messagebox") setgeometry(100,100,600,80) setStyleSheet("background-color: white;") show() } exec() } func pWork new qmessagebox(win1) { setwindowtitle("messagebox title") settext("messagebox text") setInformativeText("Do you want to save your changes?") setstandardbuttons(QMessageBox_Yes | QMessageBox_No | QMessageBox_Close) result = exec() win1 { if result = QMessageBox_Yes setwindowtitle("Yes") but result = QMessageBox_No setwindowtitle("No") but result = QMessageBox_Close setwindowtitle("Close") ok } } The application during the runtime 64.43. QMessagebox Example 724
  • 7. Ring Documentation, Release 1.9 64.44 Using QInputDialog Class In the next example we will learn about using the QInputDialog class Load "guilib.ring" New QApp { Win1 = New QWidget () { SetGeometry(100,100,400,400) SetWindowTitle("Input Dialog") New QPushButton(win1) { SetText ("Input Dialog") SetGeometry(100,100,100,30) SetClickEvent("pWork()") } Show() } exec() } Func pWork oInput = New QInputDialog(win1) { setwindowtitle("What is your name?") setgeometry(100,100,400,50) setlabeltext("User Name") settextvalue("Mahmoud") lcheck = exec() 64.44. Using QInputDialog Class 725
  • 8. Ring Documentation, Release 1.9 if lCheck win1.setwindowtitle(oInput.textvalue()) ok } The application during the runtime 64.45 Dialog Functions We have the next functions SetDialogIcon(cIconFile) MsgInfo(cTitle,cMessage) ConfirmMsg(cTitle,cMessage) --> lResult InputBox(cTitle,cMessage) --> cValue InputBoxInt(cTitle,cMessage) --> nValue InputBoxNum(cTitle,cMessage) --> nValue InputBoxPass(cTitle,cMessage) --> cValue Example load "guilib.ring" new qApp { SetDialogIcon("notepad.png") msginfo(:Ring,:Welcome) see confirmMsg(:Ring,"Are you sure?") + nl 64.45. Dialog Functions 726
  • 9. Ring Documentation, Release 1.9 see InputBoxNum(:Ring,"Enter Number(double) :") + nl see InputBox(:Ring,"Enter Value :") + nl see InputBoxInt(:Ring,"Enter Number(int)") + nl see InputBoxPass(:Ring,"Enter Password") +nl } 64.46 KeyPress and Mouse Move Events In this example we will learn how to use the Events Filter to know about KeyPress and Mouse Move Events Load "guilib.ring" new qApp { win1 = new qWidget() { setWindowTitle("Test using Event Filter!") setGeometry(100,100,400,400) setmousetracking(true) myfilter = new qallevents(win1) myfilter.setKeyPressEvent("pWork()") myfilter.setMouseButtonPressevent("pClick()") myfilter.setmousemoveevent("pMove()") installeventfilter(myfilter) show() } exec() } func pWork win1.setwindowtitle('KeyPress! : ' + myfilter.getkeycode()) func pClick new qmessagebox(win1) { setgeometry(100,100,400,100) setwindowtitle("click event!") settext("x : " + myfilter.getx() + " y : " + myfilter.gety() + " button : " + myfilter.getbutton() ) show() } func pMove win1.setwindowtitle("Mouse Move , X : " + myfilter.getx() + " Y : " + myfilter.gety() ) The application during the runtime 64.46. KeyPress and Mouse Move Events 727
  • 10. Ring Documentation, Release 1.9 64.47 Moving Objects using the Mouse In the next example we will learn how to program movable objects where the user can move a label Load "guilib.ring" lPress = false nX = 0 nY = 0 new qApp { win1 = new qWidget() { setWindowTitle("Move this label!") setGeometry(100,100,400,400) setstylesheet("background-color:white;") Label1 = new qLabel(Win1){ setGeometry(100,100,200,50) setText("Welcome") setstylesheet("font-size: 30pt") myfilter = new qallevents(label1) myfilter.setEnterevent("pEnter()") myfilter.setLeaveevent("pLeave()") 64.47. Moving Objects using the Mouse 728