//
// i set their mapping/etc. then connect them to a custom SLOT
connect(lyImgAcMapper[0], SIGNAL(mapped(int)), this, SLOT(lyImgSL(int)));
connect(lyImgAcMapper[1], SIGNAL(mapped(int)), this, SLOT(lyImgSL(int)));
connect(lyImgAcMapper[2], SIGNAL(mapped(int)), this, SLOT(lyImgSL(int)));
// the lyImgSL(int) slot looks like this
void Window::lyImgSL(int value)
{
QSignalMapper *sigmap
= qobject_cast<QSignalMapper
*>
(sender
());
//from Rajesh's post on another thread if(sigmap==lyImgAcMapper[0])
{
emit lyImgSG(0,value);
}
else if(sigmap==lyImgAcMapper[1])
{
emit lyImgSG(1,value);
}
else
{
emit lyImgSG(2,value);
}
}
// lyImgSG is then connected to another slot
//
lyImgAcMapper[0] = new QSignalMapper(button1);
lyImgAcMapper[1] = new QSignalMapper(button2);
lyImgAcMapper[2] = new QSignalMapper(button3);
// i set their mapping/etc. then connect them to a custom SLOT
connect(lyImgAcMapper[0], SIGNAL(mapped(int)), this, SLOT(lyImgSL(int)));
connect(lyImgAcMapper[1], SIGNAL(mapped(int)), this, SLOT(lyImgSL(int)));
connect(lyImgAcMapper[2], SIGNAL(mapped(int)), this, SLOT(lyImgSL(int)));
// the lyImgSL(int) slot looks like this
void Window::lyImgSL(int value)
{
QSignalMapper *sigmap = qobject_cast<QSignalMapper *>(sender()); //from Rajesh's post on another thread
if(sigmap==lyImgAcMapper[0])
{
emit lyImgSG(0,value);
}
else if(sigmap==lyImgAcMapper[1])
{
emit lyImgSG(1,value);
}
else
{
emit lyImgSG(2,value);
}
}
// lyImgSG is then connected to another slot
To copy to clipboard, switch view to plain text mode
Bookmarks