当signal and slot需要传送额外参数的时候该怎么办呢?
void MainWindow::update_data(QStringList const &data){ int const size = data.size(); for(int i = 0; i != size; ++i) { QNetworkReply *reply = theme_get_->request_html(data[i]); connect(reply, SIGNAL(finished()), this, SLOT(update_message_number())); }}void MainWindow::update_message_number(){ auto result = theme_get_->read_html(qobject_cast<QNetworkReply *>(sender()) ); if(!result.first) qDebug() << result.second; int const number = parser_.get_anime_live_message_number(result.second); anime_live_model_->set_current_message_number(/*index of the row*/, number);}
void MainWindow::update_data(QStringList const &data){ int const size = data.size(); for(int i = 0; i != size; ++i) { QNetworkReply *reply = theme_get_->request_html(data[i]); connect(reply, SIGNAL(finished()), this, SLOT(update_message_number())); mapper.insert(std::make_pair(reply, i) ); }}void MainWindow::update_message_number(){ auto result = theme_get_->read_html(qobject_cast<QNetworkReply *>(sender()) ); if(!result.first) qDebug() << result.second; int const number = parser_.get_anime_live_message_number(result.second); if(mapper.find(sender()) != mapper.end() ) anime_live_model_->set_current_message_number(mapper[sender()], number); else QTimer::single_shot(500, this, SLOT(update_message_number(number ) ) ); //如果map没有更新,会重复呼叫}