当前位置: 代码迷 >> 其他开发语言 >> QObject:connect: Cannot connect (null):finished() to QSignalMapper:地图()
  详细解决方案

QObject:connect: Cannot connect (null):finished() to QSignalMapper:地图()

热度:736   发布时间:2016-05-02 04:05:19.0
QObject::connect: Cannot connect (null)::finished() to QSignalMapper::map()
  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)));
  相关解决方案