0

PHPでGtkTreeViewから行データを取得するにはどうすればよいですか?

私の試み:

// $this->guidata = new GtkListStore();
// $this->view = new GtkTreeView($this->guidata);

$dutarray = array();

$selection = $this->view->get_selection();
$selection->select_all();

$dutArray = $selection->get_selected_rows();

助けてくれてありがとう!

レオン22に挨拶

PS:2列とn行のテーブルがあります( $this->guidata->append($row) で行を追加しました)

4

1 に答える 1

0

反復は、GtkTreeView ではなく GtkListStore に渡ります! このコードを使用すると、リストから値を取得できます!

    $this->dutArray = array();      
    $iter = $this->guidata->get_iter_first();

    //$iterIndex = 1;
    while (null != $iter)
    {   
        $key = $this->guidata->get_value($iter, 0);
        $value = $this->guidata->get_value($iter, 1);

        $this->dutArray = $this->array_push_assoc($this->dutArray, $key, $value);

        $iter = $this->guidata->iter_next($iter); // incement iterator                                  
    }   

キーと値のペアを配列に追加できる関数

    public function array_push_assoc($array, $key, $value)
    {
        $array[$key] = $value;  
        return $array;
    }
于 2012-01-25T12:43:50.837 に答える