[Gambas-user] Table view questions
ron
ronstk at ...239...
Mon Sep 13 11:19:45 CEST 2004
On Monday 13 September 2004 08:54, Eilert wrote:
> Hi Benoit,
>
> This is just what I wondered about... :-)
>
***********
> >
> > ???? You should never call the Data event handler yourself.
>
> I thought so - but "who" will do it for me?
>
It is done by QT when the cell are coming visible.
i.e after they where hidden by another form and the form moves away.
The events occur not for the whole table, only the cells that are
coming visible.
> >>while the values you give there are of no meaning - the tableview will
> >>always read in all values for all cells at a time - but you must give
> >>values because otherwise Gambas will complain.
> >
> >
> > Sorry, I don't understand your sentence...
>
> Ok, you have to call tb_Data(1,1) or tb_Data(0,0) or tb_Data(100,100) -
> not just tb_Data(). The actual values you write into the brackets don't
> matter.
>
> When I called it for the first time, I did not have this
>
> if row = 1 and column = 1 then
>
> thing there, and the tableview filled the "hello" into every cell. So I
> think, calling the Data event will fill the whole tableview at once, and
> you must make sure yourself that the values will be put into the correct
> cells by reading "row" and "column".
>
> That means, first you make up the number of rows and columns and set the
> headers. Then you call (or let call) the Data event, and with each row
> and column called, you set Text and Color and so on.
>
> If it is correct up to here, the only remaining question is: how to call
> the Data event?
You don't, it is done by the QT widget itself, that is the point.
>
> But it is rather unusual and I feel it is not the way you want it to be
> used... Now, am I really so stupid? I don't find another way of putting
> my texts and colors into it.
>
> Regards
>
> Rolf
very stupid example:
public aTBL(rows,cols) as sting[]
public sub myinit()
dim r as int
dim c as int
for c= 0 to rows-1
tableview.columns[c].text= "Col" & c
for r= 0 to cols-1
aTBL[r,c]="r=" & r & " c=" & c
next
next
end
' next wil be called by the QT widget itself
public sub tableview_DATA(row as int,column as int)
tableview.data=aTBL(row,column)
'set color depends on row/col
end
-----------------------------------
Second one, not really working
public records as result
public sub myinit()
'setup column names
with tableview
.columns=2
.columns[0].text="name"
.columns[1].text="adres"
end with
'open record set on MySQL and put in
'the records variable
end
' next wil be called by the QT widget itself
public sub tableview_DATA(row as int,column as int)
dim txt as string
records.moveto(row) 'goto record that contains the data
select case column
case 0
txt=records["name"].text
case 1
txt=records["address"].text
end select
tableview.data=txt
'set color depends on row/col
end
More information about the User
mailing list