Hi Mahmoud
In your example on: http://ring-lang.net/
How do you get the item value returned in func pWork
I want to extract the word "three" rather than the currentRow "2" when select button is pressed.
You can see what I tried below.
=========================
Load "guilib.ring"
New qApp {
win1 = new qWidget() {
setGeometry(100,100,400,400)
list1 = new qlistwidget(win1) {
setGeometry(150,100,200,200)
alist = ["one","two","three","four","five"] # <<< Item positions and values
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()
}
/*
From QListWidget Doc http://doc.qt.io/qt-4.8/qlistwidget.html
QListWidgetItem * currentItem() const
int currentRow() const
QListWidgetItem * item(int row) const
*/
func pWork
btn1.settext(string(list1.currentrow()))
See "1Row " + list1.currentRow() +nl # <<< Returns Row number selected
### These do NOT work !!!
#See " 2Item " + list1.currentItem() +nl
#See " 3Item " + list1.item() +nl
#See " 4Item " + list1.item(2) +nl
#See " 5Item " + string(list1.currentItem() ) +nl
#See " 6Item " + string( list1.item() ) +nl
#See " 7Item " + string(list1.item(2) ) +nl
func pWork2
list1 {
takeitem(currentrow())
}
Load "guilib.ring"
New qApp {
win1 = new qWidget() {
setGeometry(100,100,400,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
if list1.currentrow() > 0
btn1.settext( list1.item(list1.currentrow()).text() ) ok
func pWork2
list1 {
takeitem(currentrow())
}