Re: how get scroll_to_row working



thanks Kjell now I know why my path returned 0x0.

Now my scroll to row is working like what I had in mind, but the vertical scroll bar of scrollwindow sometime jump all the way up and then back down to the current selected row.



On Mon, Feb 13, 2012 at 8:52 PM, Kjell Ahlstedt <kjell ahlstedt bredband net> wrote:
function_append() returns a pointer to a local variable (row). That's asking for trouble!

I added your code (approximately) to the example program at
http://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/treeview/list

If I let function_append() return &row directly, the compiler (gcc 4.6.1) warns. Your trick of first copying the address to return_row makes the compiler shut up, but the error remains. It's just that the compiler doesn't find it.

A solution is to use an iterator instead of a row where possible. Like so:

Gtk::TreeModel::iterator function_append()
{
  Gtk::TreeModel::iterator iter = m_refTreeModel->append();
  Gtk::TreeModel::Row row = *iter;
  ......
  return iter;
}

void some_function()
{
  Gtk::TreeModel::iterator iter = function_append();
  scroll_to_row(iter);
}

void scroll_to_row(Gtk::TreeModel::iterator iter)
{
  Gtk::TreeModel::Path path = m_refTreeModel->get_path(iter);
  m_tree_view->scroll_to_row(path);
}


2012-02-10 01:11, kiet tran skrev:
Hi everyone,

i been trying to use scroll_to_path from a treeview and it seems to do nothing

Gtk::TreeModel::Row *function_append()
{
   Gtk::TreeModel::Row row  = *m_refTreeModel->append();
    row[m_Columns.m_col_text] = order_text;
    row[m_Columns.sort] = new_order->_get_no_of_packs();
    row[m_Columns.active_bg_color] = color;
    row[m_Columns.normal_bg_color] = "white";


Gtk::TreeModel::Row * return_row = &row;

    return return_row;
}


void some_function()
{
   Gtk::TreeModel::Row * row = function_append();

   scroll_to_row(*row);
}

void scroll_to_row( &row)
{
Gtk::TreeModel::Path path  = m_refTreeModel->get_path(row);
        m_tree_view->scroll_to_row(path);
}


Just wondering how my path is poting to NULL in scroll_to_row function and if possible if someone show me how to make this work thanks.
What I am trying to do is having the scrollwindow to always go to the bottom of the page when insert a new row.

P.S I didnt mean to sent the last email

Cheers,

Kiet Tran




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