buttons and signal_clicked with sigc::mem_fun and pointers



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi I'm new to this mailing-list  ;)
I have a little problem using pointers and buttons:
I put some check buttons in a VBox with a for loop. All the code is ok,
because when I leave the following line the program works fine.

a_CheckButtons[i-1]->signal_clicked().connect
(
	sigc::mem_fun(*this, &Preferences::on_checkbutton_clicked)(&i,1)
);

The problem will also be in the line, but I think I've not understood
well in wich way sigc::mem_func() does work

this is my code:

Preferences::Preferences()
:
m_Frame("Preferences")
{
	set_border_width(10);
	set_size_request(150, 260);
	set_title("Multiplication");

	add(m_VBox);

	m_Frame.add(m_HBox);

	for(int i=1; i<=10; i+=2)
	{
		a_CheckButtons[i-1] = new Gtk::CheckButton();
		a_CheckButtons[i-1]->set_label(to_string(i));
		a_CheckButtons[i-1]->signal_clicked().connect
		(
		sigc::mem_fun(*this, &Preferences::on_checkbutton_clicked)(&i, 1)
		);
		m_VBox_1.pack_start(*a_CheckButtons[i-1]);
	}
}

void Preferences::on_checkbutton_clicked(int &numero)
{
	cout << "checked" << numero << endl;
}

thanks
Guglie
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFCNEvXZu3DgeMsziwRAl+uAKDSOvT0ugFKQq1Qb5cW34aJS+SBngCePUNw
3WhEatBlavL/oBwQ9sM3kss=
=DNs/
-----END PGP SIGNATURE-----



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