M
Markus Pitha
Hello,
I have a window containing a table with some (dynamically created)
buttons. I want to change the buttons, when they are clicked, but with
dynamically created buttons, this issue seems to be not that easy.
Look at this methods:
void GUIAdjazenzmatrix::createTable() {
for(int i = 0; i < knotenAnzahl; i++) {
for(int j = 0; j < knotenAnzahl; j++) {
Gtk::Button* pButton = Gtk::manage(new Gtk::Button(" 0 "));
table.attach(*pButton, j, j+1, i, i+1);
pButton->signal_clicked().connect(sigc::bind<int, int>
(sigc::mem_fun(*this,
&GUIAdjazenzmatrix:nButtonClick), j, i));
}
}
}
void GUIAdjazenzmatrix:nButtonClick(int j, int i) {
//some code
}
I tried to force a Gtk::Button pointer through this signal, but I
couldn't manage it.
When I try something like this:
void GUIAdjazenzmatrix::createTable() {
for(int i = 0; i < knotenAnzahl; i++) {
for(int j = 0; j < knotenAnzahl; j++) {
Gtk::Button* pButton = Gtk::manage(new Gtk::Button(" 0 "));
table.attach(*pButton, j, j+1, i, i+1);
pButton->signal_clicked().connect(sigc::bind<int, int,
Gtk::Button*>
(sigc::mem_fun(*this,
&GUIAdjazenzmatrix:nButtonClick), j, i, pButton));
}
}
}
...I get these errors:
$ g++ GUI*.cpp Main.cpp -o Main `pkg-config gtkmm-2.4 --libs --cflags`
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h: In member
function »typename
sigc::adaptor_functor<T_functor>::deduce_result_type<T_arg1, T_arg2,
T_arg3, void, void, void, void>::type
sigc::adaptor_functor<T_functor>:perator()(T_arg1, T_arg2, T_arg3)
const [with T_arg1 = int&, T_arg2 = int&, T_arg3 = Gtk::Button*&,
T_functor = sigc::bound_mem_functor2<void, GUIAdjazenzmatrix, int, int>]«:
/usr/include/sigc++-2.0/sigc++/adaptors/bind.h:1511: instantiated from
»typename sigc::adapts<T_functor>::adaptor_type::result_type
sigc::bind_functor<-0x000000001, T_functor, T_type1, T_type2, T_type3,
sigc::nil, sigc::nil, sigc::nil, sigc::nil>:perator()() [with
T_functor = sigc::bound_mem_functor2<void, GUIAdjazenzmatrix, int, int>,
T_type1 = int, T_type2 = int, T_type3 = Gtk::Button*]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:103: instantiated from
»static T_return sigc::internal::slot_call0<T_functor,
T_return>::call_it(sigc::internal::slot_rep*) [with T_functor =
sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:110: instantiated from
»static void* (* sigc::internal::slot_call0<T_functor,
T_return>::address())(void*) [with T_functor =
sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:454: instantiated from
»sigc::slot0<T_return>::slot0(const T_functor&) [with T_functor =
sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1130: instantiated from
»sigc::slot<T_return, sigc::nil, sigc::nil, sigc::nil, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor
= sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
GUIAdjazenzmatrix.cpp:27: instantiated from here
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:123: Fehler:
....and so on..
What can i do?
Markus
I have a window containing a table with some (dynamically created)
buttons. I want to change the buttons, when they are clicked, but with
dynamically created buttons, this issue seems to be not that easy.
Look at this methods:
void GUIAdjazenzmatrix::createTable() {
for(int i = 0; i < knotenAnzahl; i++) {
for(int j = 0; j < knotenAnzahl; j++) {
Gtk::Button* pButton = Gtk::manage(new Gtk::Button(" 0 "));
table.attach(*pButton, j, j+1, i, i+1);
pButton->signal_clicked().connect(sigc::bind<int, int>
(sigc::mem_fun(*this,
&GUIAdjazenzmatrix:nButtonClick), j, i));
}
}
}
void GUIAdjazenzmatrix:nButtonClick(int j, int i) {
//some code
}
I tried to force a Gtk::Button pointer through this signal, but I
couldn't manage it.
When I try something like this:
void GUIAdjazenzmatrix::createTable() {
for(int i = 0; i < knotenAnzahl; i++) {
for(int j = 0; j < knotenAnzahl; j++) {
Gtk::Button* pButton = Gtk::manage(new Gtk::Button(" 0 "));
table.attach(*pButton, j, j+1, i, i+1);
pButton->signal_clicked().connect(sigc::bind<int, int,
Gtk::Button*>
(sigc::mem_fun(*this,
&GUIAdjazenzmatrix:nButtonClick), j, i, pButton));
}
}
}
...I get these errors:
$ g++ GUI*.cpp Main.cpp -o Main `pkg-config gtkmm-2.4 --libs --cflags`
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h: In member
function »typename
sigc::adaptor_functor<T_functor>::deduce_result_type<T_arg1, T_arg2,
T_arg3, void, void, void, void>::type
sigc::adaptor_functor<T_functor>:perator()(T_arg1, T_arg2, T_arg3)
const [with T_arg1 = int&, T_arg2 = int&, T_arg3 = Gtk::Button*&,
T_functor = sigc::bound_mem_functor2<void, GUIAdjazenzmatrix, int, int>]«:
/usr/include/sigc++-2.0/sigc++/adaptors/bind.h:1511: instantiated from
»typename sigc::adapts<T_functor>::adaptor_type::result_type
sigc::bind_functor<-0x000000001, T_functor, T_type1, T_type2, T_type3,
sigc::nil, sigc::nil, sigc::nil, sigc::nil>:perator()() [with
T_functor = sigc::bound_mem_functor2<void, GUIAdjazenzmatrix, int, int>,
T_type1 = int, T_type2 = int, T_type3 = Gtk::Button*]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:103: instantiated from
»static T_return sigc::internal::slot_call0<T_functor,
T_return>::call_it(sigc::internal::slot_rep*) [with T_functor =
sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:110: instantiated from
»static void* (* sigc::internal::slot_call0<T_functor,
T_return>::address())(void*) [with T_functor =
sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:454: instantiated from
»sigc::slot0<T_return>::slot0(const T_functor&) [with T_functor =
sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1130: instantiated from
»sigc::slot<T_return, sigc::nil, sigc::nil, sigc::nil, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor
= sigc::bind_functor<-0x000000001, sigc::bound_mem_functor2<void,
GUIAdjazenzmatrix, int, int>, int, int, Gtk::Button*, sigc::nil,
sigc::nil, sigc::nil, sigc::nil>, T_return = void]«
GUIAdjazenzmatrix.cpp:27: instantiated from here
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:123: Fehler:
....and so on..
What can i do?
Markus