signal mapping on pushbutton signal clicked
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
Code:
#include <QSignalMapper>
signals:
void clicked(int value);
public Q_SLOTS:
void changeIndex(int index);
private:
int mapValue[10];
in mapping.cpp
Code:
/* signal Mapper*/
mapValue[i] = 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 Segmentation fault ....
i dont know where i done the mistake ...it crashes here ..
Code:
connect(cicsButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
please help .... why in run time it give seg. fault ....
Re: signal mapping on pushbutton signal clicked
[offtop]
you can optimazi this code
Code:
connect(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(clicked(int)));
connect(this, SIGNAL(clicked(int)), this, SLOT(changeIndex(int)));
like this
Code:
connect(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(changeIndex(int)));
[/offtop]
could you post compilable code which reproduces a crash?
Re: signal mapping on pushbutton signal clicked
Quote:
Originally Posted by
spirit
[offtop]
you can optimazi this code
Code:
connect(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(clicked(int)));
connect(this, SIGNAL(clicked(int)), this, SLOT(changeIndex(int)));
like this
Code:
connect(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(changeIndex(int)));
[/offtop]
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 ....