Вы находитесь на странице: 1из 10

Ring Documentation, Release 1.

47.12 Using QTabWidget

In this example we will learn about using the QTabWidget class


Load "guilib.ring"

New qApp {

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

47.12. Using QTabWidget 400


Ring Documentation, Release 1.2

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

47.13. Using QTableWidget 401


Ring Documentation, Release 1.2

exec()
}

The application during the runtime

47.14 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

47.14. Using QProgressBar 402


Ring Documentation, Release 1.2

47.15 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

47.15. Using QSpinBox 403


Ring Documentation, Release 1.2

47.16 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

47.16. Using QSlider 404


Ring Documentation, Release 1.2

47.17 Using QDateEdit

In this example we will learn about using the QDateEdit class


Load "guilib.ring"

New qApp {
win1 = new qMainWindow() {
setwindowtitle("Using QDateEdit")
setGeometry(100,100,250,100)
new qdateedit(win1) {
setGeometry(20,40,220,30)
}
show()
}
exec()
}

The application during the runtime

47.17. Using QDateEdit 405


Ring Documentation, Release 1.2

47.18 Using QDial

In this example we will learn about using the QDial class


Load "guilib.ring"

New qApp {
win1 = new qMainWindow() {
setGeometry(100,100,450,500)
setwindowtitle("Using QDial")
new qdial(win1) {
setGeometry(100,100,250,300)
}
show()
}
exec()
}

The application during the runtime

47.18. Using QDial 406


Ring Documentation, Release 1.2

Another Example
Load "guilib.ring"

New qApp {
win1 = new qMainWindow()
{
setGeometry(100,100,450,500)
setwindowtitle("Using QDial")
button1 = new QPushButton(win1){
setGeometry(100,350,100,30)
settext("Increment")
setClickEvent("pIncrement()")
}

button2 = new QPushButton(win1){


setGeometry(250,350,100,30)
settext("Decrement")
setClickEvent("pDecrement()")
}
pdial = new qdial(win1) {

47.18. Using QDial 407


Ring Documentation, Release 1.2

setGeometry(100,50,250,300)
setNotchesVisible(true)
setValue(50)
SetValueChangedEvent("pDialMove()")
}
lineedit1 = new qlineedit(win1) {
setGeometry(200,400,50,30)
setalignment(Qt_AlignHCenter)
settext(string(pdial.value()))
setreturnPressedEvent("pPress()")
}
show()
}
exec()
}

func pIncrement
pdial{val=value()}
pdial.setvalue(val+1)
lineedit1{settext(string(val+1))}

func pDecrement
pdial{val=value()}
pdial.setvalue(val-1)
lineedit1{settext(string(val-1))}

func pPress
lineedit1{val=text()}
pdial.setvalue(number(val))

func pDialMove
lineedit1.settext(""+pdial.value())

47.18. Using QDial 408


Ring Documentation, Release 1.2

47.19 Using QWebView

In this example we will learn about using the QWebView class


Load "guilib.ring"

New qApp {
win1 = new qMainWindow() {
setwindowtitle("QWebView")
myweb = new qwebview(win1) {
setGeometry(10,10,600,600)
loadpage(new qurl("http://google.com"))
}
setcentralwidget(myweb)
showMaximized()
}
exec()
}

The application during the runtime

47.19. Using QWebView 409

Вам также может понравиться