You are on page 1of 10

Ring Documentation, Release 1.

57.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")

57.9. Context Menu 603


Ring Documentation, Release 1.6

}
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())
}

57.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()
}

57.10. Creating Toolbar 604


Ring Documentation, Release 1.6

The application during the runtime

57.11 Creating StatusBar

In this example we will learn about using the QStatusBar class


Load "guilib.ring"

New qApp {

win1 = new qMainWindow() {

setwindowtitle("Using QStatusbar")
setGeometry(100,100,400,400)

status1 = new qstatusbar(win1) {


showmessage("Ready!",0)
}

setstatusbar(status1)
show()
}

exec()
}

57.11. Creating StatusBar 605


Ring Documentation, Release 1.6

The application during the runtime

57.12 Using QDockWidget

In this example we will learn about using the QDockWidget class


Load "guilib.ring"

New qApp {

win1 = new qMainWindow() {

setwindowtitle("QDockWidget")
setGeometry(100,100,400,400)

label1 = new qlabel(win1) {


settext("Hello")
setGeometry(300,300,100,100)
}

label2 = new qlabel(win1) {


settext("How are you ?")
setGeometry(100,100,100,100)
}

dock1 = new qdockwidget(win1,0) {

57.12. Using QDockWidget 606


Ring Documentation, Release 1.6

setwidget(label1)
SetAllowedAreas(1)
}

dock2 = new qdockwidget(win1,0) {


setwidget(label2)
SetAllowedAreas(2)
}

adddockwidget(Qt_LeftDockWidgetArea,dock1,Qt_Horizontal)
adddockwidget(Qt_LeftDockWidgetArea,dock2,Qt_Vertical)

show()
}
exec()
}

The application during the runtime

57.13 Using QTabWidget

In this example we will learn about using the QTabWidget class


Load "guilib.ring"

New qApp {

57.13. Using QTabWidget 607


Ring Documentation, Release 1.6

win1 = new qMainWindow() {

setwindowtitle("Using QTabWidget")
setGeometry(100,100,400,400)

page1 = new qwidget() {


new qpushbutton(page1) {
settext("The First Page")
}
}

page2 = new qwidget() {


new qpushbutton(page2) {
settext("The Second Page")
}
}

page3 = new qwidget() {


new qpushbutton(page3) {
settext("The Third Page")
}
}

tab1 = new qtabwidget(win1) {


inserttab(0,page1,"Page 1")
inserttab(1,page2,"Page 2")
inserttab(2,page3,"Page 3")
setGeometry(100,100,400,400)
}

status1 = new qstatusbar(win1) {


showmessage("Ready!",0)
}

setstatusbar(status1)
showMaximized()
}

exec()
}

The application during the runtime

57.13. Using QTabWidget 608


Ring Documentation, Release 1.6

57.14 Using QTableWidget

In this example we will learn about using the QTableWidget class


Load "guilib.ring"

New qApp {

win1 = new qMainWindow() {

setGeometry(100,100,1100,370)
setwindowtitle("Using QTableWidget")

Table1 = new qTableWidget(win1) {

setrowcount(10) setcolumncount(10)
setGeometry(0,0,800,400)
setselectionbehavior(QAbstractItemView_SelectRows)

for x = 1 to 10
for y = 1 to 10
item1 = new qtablewidgetitem("R"+X+"C"+Y)
setitem(x-1,y-1,item1)
next
next

setcentralwidget(table1)
show()

57.14. Using QTableWidget 609


Ring Documentation, Release 1.6

exec()
}

The application during the runtime

57.15 Using QProgressBar

In this example we will learn about using the QProgressBar class


Load "guilib.ring"

New qApp {
win1 = new qMainWindow() {

setGeometry(100,100,600,150)
setwindowtitle("Using QProgressBar")

for x = 10 to 100 step 10


new qprogressbar(win1) {
setGeometry(100,x,350,30)
setvalue(x)
}
next

show()
}
exec()
}

The application during the runtime

57.15. Using QProgressBar 610


Ring Documentation, Release 1.6

57.16 Using QSpinBox

In this example we will learn about using the QSpinBox class


Load "guilib.ring"

New qApp {
win1 = new qMainWindow() {
setGeometry(100,100,450,260)
setwindowtitle("Using QSpinBox")
new qspinbox(win1) {
setGeometry(50,100,350,30)
setvalue(50)
}
show()
}
exec()
}

The application during the runtime

57.16. Using QSpinBox 611


Ring Documentation, Release 1.6

57.17 Using QSlider

In this example we will learn about using the QSlider class


Load "guilib.ring"

New qApp {

win1 = new qMainWindow() {

setGeometry(100,100,500,400)
setwindowtitle("Using QSlider")

new qslider(win1) {
setGeometry(100,100,50,130)
settickinterval(50)
}

new qslider(win1) {
setGeometry(100,250,250,30)
settickinterval(50)
setorientation(Qt_Horizontal)
}

show()

exec()
}

The application during the runtime

57.17. Using QSlider 612

You might also like