QListIterator<QToolButton *> iter(numList);
QListIterator<QPropertyAnimation *> iterAin(aniList);
QPropertyAnimation *tempAni;
int i = 0;
if(iter.hasNext()){ //mySignalIn -->> shanliang
connect(this,SIGNAL(mySignalIn()),s_pSignalMapper,SLOT(map()));
s_pSignalMapper->setMapping(this,i);
i++;
}
while(iter.hasNext()){ //move -->> shanliang
tempAni = iterAin.next();
if(!tempAni)qDebug() << "NULL";
connect(tempAni,SIGNAL(finished()),s_pSignalMapper,SLOT(map()));
s_pSignalMapper->setMapping(tempAni,i);
i++;
}
connect(iterAin.next(),SIGNAL(finished()),this,SLOT(collect()));
connect(s_pSignalMapper,SIGNAL(mapped(int)),this,SLOT(shanLiang(int)));
编译不报错,一运行就出错。
谁能告诉我为什么??
Qt QSignalMapper connect signal
------解决方案--------------------
QListIterator<QToolButton *> iter(numList);
QListIterator<QPropertyAnimation *> iterAin(aniList);
QToolButton *tempButton;
int i = 0;
if(iter.hasNext()){
tempButton = iter.next();
connect(this,SIGNAL(mySignalIn()),tempButton,SLOT(click()));
connect(tempButton,SIGNAL(clicked()),s_pSignalMapper,SLOT(map()));
s_pSignalMapper->setMapping(tempButton,i);
i++;
}
while(iter.hasNext()){
tempButton = iter.next();
connect(iterAin.next(),SIGNAL(finished()),tempButton,SLOT(click()));
connect(tempButton,SIGNAL(clicked()),s_pSignalMapper,SLOT(map()));
s_pSignalMapper->setMapping(tempButton,i);
i++;
}
connect(iterAin.next(),SIGNAL(finished()),this,SLOT(collect()));
connect(s_pSignalMapper,SIGNAL(mapped(int)),this,SLOT(shanLiang(int)));
//shanlaing --> move
connect(this,SIGNAL(mySignalMove(int)),this,SLOT(SetAnimation(int)));