ListStore with an unknown number of columns?



I'm writing a sub to create a ListStore to hold data for a combo box.
I'd like to be able to have a variable number of columns, driven by the number of fields I pass into the sub.

Then I'd do something like:

    while (my @row = $sth->fetchrow_array) {
my $iter = $liststore->append;
        $liststore->set($iter, @row);
}

But the 'set' method of ListStore wants the fields passed as separate values.

In the examples folder I found the following code:

    for ($i = 0 ; $i < 50 ; $i+=5) {
        my $iter = $store->append;
        $store->set ($iter, 0 => "$i");
    }

So I tried constructing a hash of data ( which gives me the ability to control the number of fields ), eg:

{
   0   => $primary_key,
   1   => $string_1,
   2   => $string_2
}

But when I try to pass that into the 'set' method it gives the same complaint as my first attempt:

Usage: set(list_store, iter, col1, val1, ...)

Is there a way to do what I want?

--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au
website: http://www.nusconsulting.com.au
Title: CanIt Vote for ID 51694

The following links have been placed here by the NUS Consulting internal spam filter and are for use by NUS Consulting staff only.
Please ingore these links.
Spam
Not spam
Forget previous vote


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]