Ring Documentation, Release 1.5.4
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
56.4. Using the QListWidget Class 575
Ring Documentation, Release 1.5.4
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()
56.4. Using the QListWidget Class 576
Ring Documentation, Release 1.5.4
win1.setwindowtitle("After Delete - NbrOfItems: " + nbrOfItems +
" CurItemNbr: " + curItemNbr +" CurValue: " + curValue )
}
56.5 Using QTreeView and QFileSystemModel
In this example we will learn how to use the QTreeView widget to represent the File System
Load "guilib.ring"
New qApp {
win1 = New qWidget() {
setwindowtitle("Using QTreeView and QFileSystemModel")
setGeometry(100,100,500,400)
New qtreeview(win1) {
setGeometry(00,00,500,400)
oDir = new QDir()
ofile = new QFileSystemModel()
ofile.setrootpath(oDir.currentpath())
setmodel(ofile)
}
show()
}
exec()
}
The application during the runtime
56.5. Using QTreeView and QFileSystemModel 577
Ring Documentation, Release 1.5.4
56.6 Using QTreeWidget and QTreeWidgetItem
In this example we will learn about using the QTreeWidget and QTreeWidgetItem classes
Load "guilib.ring"
New qApp {
win1 = new qWidget() {
setwindowtitle("TreeWidget")
setGeometry(100,100,400,400)
layout1 = new qvboxlayout()
tree1 = new qtreewidget(win1) {
setGeometry(00,00,400,400)
setcolumncount(1)
myitem = new qtreewidgetitem()
myitem.settext(0,"The First Step")
addtoplevelitem(myitem)
for x = 1 to 10
myitem2 = new qtreewidgetitem()
myitem2.settext(0,"hello"+x)
myitem.addchild(myitem2)
56.6. Using QTreeWidget and QTreeWidgetItem 578
Ring Documentation, Release 1.5.4
for y = 1 to 10
myitem3 = new qtreewidgetitem()
myitem3.settext(0,"hello"+x)
myitem2.addchild(myitem3)
next
next
setheaderlabel("Steps Tree")
}
layout1.addwidget(tree1)
setlayout(layout1)
show()
}
exec()
}
The application during the runtime
56.7 Using QComboBox Class
In this example we will learn about using the QComboBox class
56.7. Using QComboBox Class 579
Ring Documentation, Release 1.5.4
Load "guilib.ring"
New qApp {
win1 = new qWidget() {
setwindowtitle("Using QComboBox")
setGeometry(100,100,400,400)
New QComboBox(win1) {
setGeometry(150,100,200,30)
alist = ["one","two","three","four","five"]
for x in aList additem(x,0) next
}
show()
}
exec()
}
The application during the runtime
56.8 Creating Menubar
In this example we will learn about using the QMenuBar class
56.8. Creating Menubar 580
Ring Documentation, Release 1.5.4
Load "guilib.ring"
MyApp = New qApp {
win1 = new qWidget() {
setwindowtitle("Using QMenubar")
setGeometry(100,100,400,400)
menu1 = new qmenubar(win1) {
sub1 = addmenu("File")
sub2 = addmenu("Edit")
sub3 = addmenu("Help")
sub1 {
oAction = new qAction(win1) {
settext("New")
}
addaction(oAction)
oAction = new qAction(win1) {
settext("Open")
}
addaction(oAction)
oAction = new qAction(win1) {
settext("Save")
}
addaction(oAction)
oAction = new qAction(win1) {
settext("Save As")
}
addaction(oAction)
addseparator()
oAction = new qaction(win1) {
settext("Exit")
setclickevent("myapp.quit()")
}
addaction(oAction)
}
sub2 {
oAction = new qAction(win1) {
settext("Cut")
}
addaction(oAction)
oAction = new qAction(win1) {
settext("Copy")
}
addaction(oAction)
oAction = new qAction(win1) {
settext("Paste")
}
addaction(oAction)
addseparator()
oAction = new qAction(win1) {
settext("Select All")
}
addaction(oAction)
}
sub3 {
oAction = new qAction(win1) {
56.8. Creating Menubar 581
Ring Documentation, Release 1.5.4
settext("Reference")
}
addaction(oAction)
sub4 = addmenu("Sub Menu")
sub4 {
oAction = new qAction(win1) {
settext("Website")
}
addaction(oAction)
oAction = new qAction(win1) {
settext("Forum")
}
addaction(oAction)
oAction = new qAction(win1) {
settext("Blog")
}
addaction(oAction)
}
addseparator()
oAction = new qAction(win1) {
settext("About")
}
addaction(oAction)
}
}
show()
}
exec()
}
The application during the runtime
56.8. Creating Menubar 582
Ring Documentation, Release 1.5.4
56.9 Context Menu
Example:
load "guilib.ring"
new qApp {
win = new qwidget() {
setwindowtitle("Context Menu")
resize(400,400)
myfilter = new qAllEvents(win) {
setContextmenuEvent("mymenu()")
}
installeventfilter(myfilter)
show()
}
exec()
}
func mymenu
new qMenu(win) {
oAction = new qAction(win) {
settext("new")
SetCLickevent("See :New")
56.9. Context Menu 583
Ring Documentation, Release 1.5.4
}
addaction(oAction)
oAction = new qAction(win) {
settext("open")
SetCLickevent("See :Open")
}
addaction(oAction)
oAction = new qAction(win) {
settext("save")
SetCLickevent("See :Save")
}
addaction(oAction)
oAction = new qAction(win) {
settext("close")
SetCLickevent("See :Close")
}
addaction(oAction)
oCursor = new qCursor()
exec(oCursor.pos())
}
56.10 Creating Toolbar
In this example we will learn about using the QToolBar class
Load "guilib.ring"
New qApp {
win1 = new qMainWindow() {
setwindowtitle("Using QToolbar")
setGeometry(100,100,600,400)
abtns = [
new qpushbutton(win1) { settext("Add") } ,
new qpushbutton(win1) { settext("Edit") } ,
new qpushbutton(win1) { settext("Find") } ,
new qpushbutton(win1) { settext("Delete") } ,
new qpushbutton(win1) { settext("Exit")
setclickevent("win1.close()") }
]
tool1 = new qtoolbar(win1) {
for x in abtns addwidget(x) addseparator() next
setmovable(true)
setGeometry(0,0,500,30)
setFloatable(true)
}
show()
}
exec()
}
56.10. Creating Toolbar 584

More Related Content

PDF
The Ring programming language version 1.3 book - Part 44 of 88
PDF
The Ring programming language version 1.4 book - Part 16 of 30
PDF
The Ring programming language version 1.7 book - Part 71 of 196
PDF
The Ring programming language version 1.5.4 book - Part 66 of 185
PDF
The Ring programming language version 1.8 book - Part 68 of 202
PDF
The Ring programming language version 1.7 book - Part 66 of 196
PDF
The Ring programming language version 1.2 book - Part 46 of 84
PDF
The Ring programming language version 1.2 book - Part 41 of 84
The Ring programming language version 1.3 book - Part 44 of 88
The Ring programming language version 1.4 book - Part 16 of 30
The Ring programming language version 1.7 book - Part 71 of 196
The Ring programming language version 1.5.4 book - Part 66 of 185
The Ring programming language version 1.8 book - Part 68 of 202
The Ring programming language version 1.7 book - Part 66 of 196
The Ring programming language version 1.2 book - Part 46 of 84
The Ring programming language version 1.2 book - Part 41 of 84

What's hot (20)

PDF
The Ring programming language version 1.8 book - Part 73 of 202
PDF
The Ring programming language version 1.2 book - Part 48 of 84
PDF
The Ring programming language version 1.8 book - Part 69 of 202
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.7 book - Part 67 of 196
PDF
The Ring programming language version 1.2 book - Part 49 of 84
PDF
The Ring programming language version 1.5.3 book - Part 71 of 184
PDF
The Ring programming language version 1.3 book - Part 49 of 88
PDF
The Ring programming language version 1.6 book - Part 70 of 189
PDF
The Ring programming language version 1.8 book - Part 74 of 202
PDF
The Ring programming language version 1.7 book - Part 69 of 196
PDF
The Ring programming language version 1.7 book - Part 72 of 196
PDF
The Ring programming language version 1.8 book - Part 67 of 202
PDF
The Ring programming language version 1.5.2 book - Part 59 of 181
PDF
The Ring programming language version 1.5.1 book - Part 64 of 180
PDF
The Ring programming language version 1.5.4 book - Part 63 of 185
PDF
The Ring programming language version 1.5.1 book - Part 58 of 180
PDF
The Ring programming language version 1.8 book - Part 71 of 202
PDF
The Ring programming language version 1.5.1 book - Part 57 of 180
The Ring programming language version 1.8 book - Part 73 of 202
The Ring programming language version 1.2 book - Part 48 of 84
The Ring programming language version 1.8 book - Part 69 of 202
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.7 book - Part 67 of 196
The Ring programming language version 1.2 book - Part 49 of 84
The Ring programming language version 1.5.3 book - Part 71 of 184
The Ring programming language version 1.3 book - Part 49 of 88
The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.7 book - Part 69 of 196
The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.8 book - Part 67 of 202
The Ring programming language version 1.5.2 book - Part 59 of 181
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.4 book - Part 63 of 185
The Ring programming language version 1.5.1 book - Part 58 of 180
The Ring programming language version 1.8 book - Part 71 of 202
The Ring programming language version 1.5.1 book - Part 57 of 180

Similar to The Ring programming language version 1.5.4 book - Part 61 of 185 (20)

PDF
The Ring programming language version 1.6 book - Part 64 of 189
PDF
The Ring programming language version 1.4.1 book - Part 16 of 31
PDF
The Ring programming language version 1.6 book - Part 63 of 189
PDF
The Ring programming language version 1.10 book - Part 73 of 212
PDF
The Ring programming language version 1.5.2 book - Part 58 of 181
PDF
The Ring programming language version 1.5.3 book - Part 72 of 184
PDF
The Ring programming language version 1.5.4 book - Part 62 of 185
PDF
The Ring programming language version 1.2 book - Part 43 of 84
PDF
The Ring programming language version 1.5.4 book - Part 67 of 185
PDF
The Ring programming language version 1.3 book - Part 45 of 88
PDF
The Ring programming language version 1.7 book - Part 65 of 196
PDF
The Ring programming language version 1.4.1 book - Part 17 of 31
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.5.3 book - Part 70 of 184
PDF
The Ring programming language version 1.9 book - Part 78 of 210
PDF
The Ring programming language version 1.2 book - Part 42 of 84
PDF
The Ring programming language version 1.5 book - Part 11 of 31
PDF
The Ring programming language version 1.9 book - Part 71 of 210
PDF
The Ring programming language version 1.4 book - Part 17 of 30
The Ring programming language version 1.6 book - Part 64 of 189
The Ring programming language version 1.4.1 book - Part 16 of 31
The Ring programming language version 1.6 book - Part 63 of 189
The Ring programming language version 1.10 book - Part 73 of 212
The Ring programming language version 1.5.2 book - Part 58 of 181
The Ring programming language version 1.5.3 book - Part 72 of 184
The Ring programming language version 1.5.4 book - Part 62 of 185
The Ring programming language version 1.2 book - Part 43 of 84
The Ring programming language version 1.5.4 book - Part 67 of 185
The Ring programming language version 1.3 book - Part 45 of 88
The Ring programming language version 1.7 book - Part 65 of 196
The Ring programming language version 1.4.1 book - Part 17 of 31
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.5.3 book - Part 70 of 184
The Ring programming language version 1.9 book - Part 78 of 210
The Ring programming language version 1.2 book - Part 42 of 84
The Ring programming language version 1.5 book - Part 11 of 31
The Ring programming language version 1.9 book - Part 71 of 210
The Ring programming language version 1.4 book - Part 17 of 30

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)

PPTX
Presentation - Principles of Instructional Design.pptx
PDF
TrustArc Webinar - Data Minimization in Practice_ Reducing Risk, Enhancing Co...
PPTX
Report in SIP_Distance_Learning_Technology_Impact.pptx
PDF
Technical Debt in the AI Coding Era - By Antonio Bianco
PDF
Ebook - The Future of AI A Comprehensive Guide.pdf
PDF
TicketRoot: Event Tech Solutions Deck 2025
PPTX
maintenance powerrpoint for adaprive and preventive
PPTX
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
PDF
FASHION-DRIVEN TEXTILES AS A CRYSTAL OF A NEW STREAM FOR STAKEHOLDER CAPITALI...
PDF
Examining Bias in AI Generated News Content.pdf
PDF
substrate PowerPoint Presentation basic one
PPTX
Blending method and technology for hydrogen.pptx
PPTX
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
PDF
The Digital Engine Room: Unlocking APAC’s Economic and Digital Potential thro...
PDF
Human Computer Interaction Miterm Lesson
PDF
Introduction to c language from lecture slides
PPTX
CRM(Customer Relationship Managmnet) Presentation
PDF
Decision Optimization - From Theory to Practice
PDF
NewMind AI Journal Monthly Chronicles - August 2025
PPTX
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
Presentation - Principles of Instructional Design.pptx
TrustArc Webinar - Data Minimization in Practice_ Reducing Risk, Enhancing Co...
Report in SIP_Distance_Learning_Technology_Impact.pptx
Technical Debt in the AI Coding Era - By Antonio Bianco
Ebook - The Future of AI A Comprehensive Guide.pdf
TicketRoot: Event Tech Solutions Deck 2025
maintenance powerrpoint for adaprive and preventive
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
FASHION-DRIVEN TEXTILES AS A CRYSTAL OF A NEW STREAM FOR STAKEHOLDER CAPITALI...
Examining Bias in AI Generated News Content.pdf
substrate PowerPoint Presentation basic one
Blending method and technology for hydrogen.pptx
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
The Digital Engine Room: Unlocking APAC’s Economic and Digital Potential thro...
Human Computer Interaction Miterm Lesson
Introduction to c language from lecture slides
CRM(Customer Relationship Managmnet) Presentation
Decision Optimization - From Theory to Practice
NewMind AI Journal Monthly Chronicles - August 2025
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com

The Ring programming language version 1.5.4 book - Part 61 of 185

  • 1. Ring Documentation, Release 1.5.4 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 56.4. Using the QListWidget Class 575
  • 2. Ring Documentation, Release 1.5.4 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() 56.4. Using the QListWidget Class 576
  • 3. Ring Documentation, Release 1.5.4 win1.setwindowtitle("After Delete - NbrOfItems: " + nbrOfItems + " CurItemNbr: " + curItemNbr +" CurValue: " + curValue ) } 56.5 Using QTreeView and QFileSystemModel In this example we will learn how to use the QTreeView widget to represent the File System Load "guilib.ring" New qApp { win1 = New qWidget() { setwindowtitle("Using QTreeView and QFileSystemModel") setGeometry(100,100,500,400) New qtreeview(win1) { setGeometry(00,00,500,400) oDir = new QDir() ofile = new QFileSystemModel() ofile.setrootpath(oDir.currentpath()) setmodel(ofile) } show() } exec() } The application during the runtime 56.5. Using QTreeView and QFileSystemModel 577
  • 4. Ring Documentation, Release 1.5.4 56.6 Using QTreeWidget and QTreeWidgetItem In this example we will learn about using the QTreeWidget and QTreeWidgetItem classes Load "guilib.ring" New qApp { win1 = new qWidget() { setwindowtitle("TreeWidget") setGeometry(100,100,400,400) layout1 = new qvboxlayout() tree1 = new qtreewidget(win1) { setGeometry(00,00,400,400) setcolumncount(1) myitem = new qtreewidgetitem() myitem.settext(0,"The First Step") addtoplevelitem(myitem) for x = 1 to 10 myitem2 = new qtreewidgetitem() myitem2.settext(0,"hello"+x) myitem.addchild(myitem2) 56.6. Using QTreeWidget and QTreeWidgetItem 578
  • 5. Ring Documentation, Release 1.5.4 for y = 1 to 10 myitem3 = new qtreewidgetitem() myitem3.settext(0,"hello"+x) myitem2.addchild(myitem3) next next setheaderlabel("Steps Tree") } layout1.addwidget(tree1) setlayout(layout1) show() } exec() } The application during the runtime 56.7 Using QComboBox Class In this example we will learn about using the QComboBox class 56.7. Using QComboBox Class 579
  • 6. Ring Documentation, Release 1.5.4 Load "guilib.ring" New qApp { win1 = new qWidget() { setwindowtitle("Using QComboBox") setGeometry(100,100,400,400) New QComboBox(win1) { setGeometry(150,100,200,30) alist = ["one","two","three","four","five"] for x in aList additem(x,0) next } show() } exec() } The application during the runtime 56.8 Creating Menubar In this example we will learn about using the QMenuBar class 56.8. Creating Menubar 580
  • 7. Ring Documentation, Release 1.5.4 Load "guilib.ring" MyApp = New qApp { win1 = new qWidget() { setwindowtitle("Using QMenubar") setGeometry(100,100,400,400) menu1 = new qmenubar(win1) { sub1 = addmenu("File") sub2 = addmenu("Edit") sub3 = addmenu("Help") sub1 { oAction = new qAction(win1) { settext("New") } addaction(oAction) oAction = new qAction(win1) { settext("Open") } addaction(oAction) oAction = new qAction(win1) { settext("Save") } addaction(oAction) oAction = new qAction(win1) { settext("Save As") } addaction(oAction) addseparator() oAction = new qaction(win1) { settext("Exit") setclickevent("myapp.quit()") } addaction(oAction) } sub2 { oAction = new qAction(win1) { settext("Cut") } addaction(oAction) oAction = new qAction(win1) { settext("Copy") } addaction(oAction) oAction = new qAction(win1) { settext("Paste") } addaction(oAction) addseparator() oAction = new qAction(win1) { settext("Select All") } addaction(oAction) } sub3 { oAction = new qAction(win1) { 56.8. Creating Menubar 581
  • 8. Ring Documentation, Release 1.5.4 settext("Reference") } addaction(oAction) sub4 = addmenu("Sub Menu") sub4 { oAction = new qAction(win1) { settext("Website") } addaction(oAction) oAction = new qAction(win1) { settext("Forum") } addaction(oAction) oAction = new qAction(win1) { settext("Blog") } addaction(oAction) } addseparator() oAction = new qAction(win1) { settext("About") } addaction(oAction) } } show() } exec() } The application during the runtime 56.8. Creating Menubar 582
  • 9. Ring Documentation, Release 1.5.4 56.9 Context Menu Example: load "guilib.ring" new qApp { win = new qwidget() { setwindowtitle("Context Menu") resize(400,400) myfilter = new qAllEvents(win) { setContextmenuEvent("mymenu()") } installeventfilter(myfilter) show() } exec() } func mymenu new qMenu(win) { oAction = new qAction(win) { settext("new") SetCLickevent("See :New") 56.9. Context Menu 583
  • 10. Ring Documentation, Release 1.5.4 } addaction(oAction) oAction = new qAction(win) { settext("open") SetCLickevent("See :Open") } addaction(oAction) oAction = new qAction(win) { settext("save") SetCLickevent("See :Save") } addaction(oAction) oAction = new qAction(win) { settext("close") SetCLickevent("See :Close") } addaction(oAction) oCursor = new qCursor() exec(oCursor.pos()) } 56.10 Creating Toolbar In this example we will learn about using the QToolBar class Load "guilib.ring" New qApp { win1 = new qMainWindow() { setwindowtitle("Using QToolbar") setGeometry(100,100,600,400) abtns = [ new qpushbutton(win1) { settext("Add") } , new qpushbutton(win1) { settext("Edit") } , new qpushbutton(win1) { settext("Find") } , new qpushbutton(win1) { settext("Delete") } , new qpushbutton(win1) { settext("Exit") setclickevent("win1.close()") } ] tool1 = new qtoolbar(win1) { for x in abtns addwidget(x) addseparator() next setmovable(true) setGeometry(0,0,500,30) setFloatable(true) } show() } exec() } 56.10. Creating Toolbar 584