PDA

View Full Version : signal mapping on pushbutton signal clicked



wagmare
17th March 2009, 07:53
hi friends,
i try to set the QPushButton() signal clicked() to connect
a slot changeIndex(int)

so i try signal Mapper so i do
mapping .h


#include <QSignalMapper>

signals:
void clicked(int value);

public Q_SLOTS:
void changeIndex(int index);

private:
QSignalMapper *signalMapper;
int mapValue[10];


in mapping.cpp


/* signal Mapper*/
mapValue = 2;
connect(cicsButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
signalMapper->setMapping(cicsButton, mapValue[1]);

connect(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(clicked(int)));
connect(this, SIGNAL(clicked(int)), this, SLOT(changeIndex(int)));


it compiled perfectly but when i run core dumped
when i try execute it gives [I]Segmentation fault ....

i dont know where i done the mistake ...it crashes here ..


connect(cicsButton, SIGNAL(clicked()), signalMapper, SLOT(map()));


please help .... why in run time it give seg. fault ....

spirit
17th March 2009, 08:08
you can optimazi this code


connect(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(clicked(int)));
connect(this, SIGNAL(clicked(int)), this, SLOT(changeIndex(int)));

like this


connect(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(changeIndex(int)));



could you post compilable code which reproduces a crash?

wagmare
17th March 2009, 08:54
you can optimazi this code


connect(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(clicked(int)));
connect(this, SIGNAL(clicked(int)), this, SLOT(changeIndex(int)));

like this


connect(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(changeIndex(int)));



could you post compilable code which reproduces a crash?
thanks for reply ...
sorry to the forum members ... i forget to initialize signalMapper
signalMapper = new QSignalMapper();
now its working ... sorry for this post ....