SlideShare a Scribd company logo
Ring Documentation, Release 1.5.3
exec()
}
Func draw
p1 = new qpicture()
color = new qcolor() {
setrgb(0,0,255,255)
}
pen = new qpen() {
setcolor(color)
setwidth(10)
}
new qpainter() {
begin(p1)
setpen(pen)
drawline(500,150,950,450)
drawline(950,550,500,150)
endpaint()
}
label1 { setpicture(p1) show() }
The application during the runtime
56.34. Drawing using QPainter 615
Ring Documentation, Release 1.5.3
56.35 Printing using QPrinter
In this example we will learn how to print to PDF file using QPrinter
Load "guilib.ring"
new qApp {
win1 = new qwidget() {
setwindowtitle("Printer")
setgeometry(100,100,500,500)
myweb = new qwebview(win1) {
setgeometry(100,100,1000,500)
loadpage(new qurl("http://google.com"))
}
new qpushbutton(win1) {
setGeometry(20,20,100,30)
settext("Print")
setclickevent("print()")
}
showmaximized()
56.35. Printing using QPrinter 616
Ring Documentation, Release 1.5.3
}
exec()
}
func print
printer1 = new qPrinter(0) {
setoutputformat(1) # 1 = pdf
setoutputfilename("test.pdf")
painter = new qpainter() {
begin(printer1)
myfont = new qfont("Times",50,-1,0)
setfont(myfont)
drawtext(100,100,"test")
printer1.newpage()
drawtext(100,100,"test2")
endpaint()
}
}
printer1 = new qPrinter(0) {
setoutputformat(1)
setoutputfilename("test2.pdf")
myweb.print(printer1)
myweb.show()
}
system ("test.pdf")
system ("test2.pdf")
56.36 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() {
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()
}
56.36. Creating More than one Window 617
Ring Documentation, Release 1.5.3
func second
win2 = new qwidget() {
setwindowtitle("Second")
setgeometry(100,100,500,500)
setwindowflags(Qt_dialog)
show()
}
The application during the runtime
56.37 Playing Sound
Example:
Load "guilib.ring"
new qapp {
win1 = new qwidget() {
setwindowtitle("play sound!") show()
}
new qmediaplayer() {
setmedia(new qurl("footstep.wav"))
setvolume(50) play()
}
exec()
}
56.38 Using the QColorDialog Class
Example:
56.37. Playing Sound 618
Ring Documentation, Release 1.5.3
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
56.38. Using the QColorDialog Class 619
Ring Documentation, Release 1.5.3
56.39 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()
}
The application during the runtime
56.40 Movable Label Example
Load "guilib.ring"
new qApp {
win1 = new qWidget()
{
56.39. Using qLCDNumber Class 620
Ring Documentation, Release 1.5.3
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
56.41 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)
56.41. QMessagebox Example 621
Ring Documentation, Release 1.5.3
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
56.42 Using QInputDialog Class
In the next example we will learn about using the QInputDialog class
56.42. Using QInputDialog Class 622
Ring Documentation, Release 1.5.3
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()
if lCheck win1.setwindowtitle(oInput.textvalue()) ok
}
The application during the runtime
56.42. Using QInputDialog Class 623
Ring Documentation, Release 1.5.3
56.43 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
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
}
56.43. Dialog Functions 624

More Related Content

What's hot (20)

PDF
The Ring programming language version 1.5.4 book - Part 67 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 76 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.4.1 book - Part 17 of 31
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 46 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 67 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 45 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 70 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 49 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 69 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 48 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 73 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 68 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 47 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 71 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 67 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 63 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 76 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 61 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 65 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 70 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 67 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 76 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.4.1 book - Part 17 of 31
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 46 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 67 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 45 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 70 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 49 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 69 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 48 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 73 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 68 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 47 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 71 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 67 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 63 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 76 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 61 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 65 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 70 of 202
Mahmoud Samir Fayed
 

Similar to The Ring programming language version 1.5.3 book - Part 75 of 184 (18)

PDF
The Ring programming language version 1.7 book - Part 69 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 72 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 71 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 68 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 62 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 70 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 74 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 72 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5 book - Part 11 of 31
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 60 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 75 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 66 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 68 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 59 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 62 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 66 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 73 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 63 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 69 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 72 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 71 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 68 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 62 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 70 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 74 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 72 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.5 book - Part 11 of 31
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 60 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 75 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 66 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 68 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 59 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 62 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 66 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 73 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 63 of 185
Mahmoud Samir Fayed
 
Ad

More from Mahmoud Samir Fayed (20)

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

Recently uploaded (20)

PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Biography of Daniel Podor.pdf
Daniel Podor
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Designing Production-Ready AI Agents
Kunal Rai
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 

The Ring programming language version 1.5.3 book - Part 75 of 184

  • 1. Ring Documentation, Release 1.5.3 exec() } Func draw p1 = new qpicture() color = new qcolor() { setrgb(0,0,255,255) } pen = new qpen() { setcolor(color) setwidth(10) } new qpainter() { begin(p1) setpen(pen) drawline(500,150,950,450) drawline(950,550,500,150) endpaint() } label1 { setpicture(p1) show() } The application during the runtime 56.34. Drawing using QPainter 615
  • 2. Ring Documentation, Release 1.5.3 56.35 Printing using QPrinter In this example we will learn how to print to PDF file using QPrinter Load "guilib.ring" new qApp { win1 = new qwidget() { setwindowtitle("Printer") setgeometry(100,100,500,500) myweb = new qwebview(win1) { setgeometry(100,100,1000,500) loadpage(new qurl("http://google.com")) } new qpushbutton(win1) { setGeometry(20,20,100,30) settext("Print") setclickevent("print()") } showmaximized() 56.35. Printing using QPrinter 616
  • 3. Ring Documentation, Release 1.5.3 } exec() } func print printer1 = new qPrinter(0) { setoutputformat(1) # 1 = pdf setoutputfilename("test.pdf") painter = new qpainter() { begin(printer1) myfont = new qfont("Times",50,-1,0) setfont(myfont) drawtext(100,100,"test") printer1.newpage() drawtext(100,100,"test2") endpaint() } } printer1 = new qPrinter(0) { setoutputformat(1) setoutputfilename("test2.pdf") myweb.print(printer1) myweb.show() } system ("test.pdf") system ("test2.pdf") 56.36 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() { 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() } 56.36. Creating More than one Window 617
  • 4. Ring Documentation, Release 1.5.3 func second win2 = new qwidget() { setwindowtitle("Second") setgeometry(100,100,500,500) setwindowflags(Qt_dialog) show() } The application during the runtime 56.37 Playing Sound Example: Load "guilib.ring" new qapp { win1 = new qwidget() { setwindowtitle("play sound!") show() } new qmediaplayer() { setmedia(new qurl("footstep.wav")) setvolume(50) play() } exec() } 56.38 Using the QColorDialog Class Example: 56.37. Playing Sound 618
  • 5. Ring Documentation, Release 1.5.3 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 56.38. Using the QColorDialog Class 619
  • 6. Ring Documentation, Release 1.5.3 56.39 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() } The application during the runtime 56.40 Movable Label Example Load "guilib.ring" new qApp { win1 = new qWidget() { 56.39. Using qLCDNumber Class 620
  • 7. Ring Documentation, Release 1.5.3 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 56.41 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) 56.41. QMessagebox Example 621
  • 8. Ring Documentation, Release 1.5.3 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 56.42 Using QInputDialog Class In the next example we will learn about using the QInputDialog class 56.42. Using QInputDialog Class 622
  • 9. Ring Documentation, Release 1.5.3 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() if lCheck win1.setwindowtitle(oInput.textvalue()) ok } The application during the runtime 56.42. Using QInputDialog Class 623
  • 10. Ring Documentation, Release 1.5.3 56.43 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 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 } 56.43. Dialog Functions 624