두 개의 QNetworkRequest가 있습니다.Qt QNetworkAccessManager 및 여러 QNetworkReply
다른 방법으로 완성 된 신호를 처리하고 싶습니다.
예를 들어이
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
GetUserData();
connect(nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(GetUserDataCompleted(QNetworkReply*)));
GetMessages();
connect(nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(GetMessagesCompleted(QNetworkReply*)));
}
내가> deleteLater replay- 시도
이 내 하나의 방법()의 코드; 그러나 같은 결과
나에게 당신은 역할 요청 후 찾고 있습니다 RequestSender
클래스를 만들 수 있습니다
void MainWindow::GetUserDataCompleted(QNetworkReply *replay)
{
if(replay->error() == QNetworkReply::NoError)
{
QString getData = replay->readAll();
QMessageBox msg;
if(getData == "1")
{
msg.setText("User Is not Exits");
}
else
{
QDomDocument doc;
if(doc.setContent(getData))
{
QDomElement domElem = doc.documentElement();
QDomNode n = domElem.firstChild();
while(!n.isNull()) {
QDomElement e = n.toElement(); // try to convert the node to an element.
if(!e.isNull()) {
msg.setText(e.namedItem("Image").childNodes().at(0).nodeValue());
msg.exec();
}
n = n.nextSibling();
}
}
replay->deleteLater();
}
}
}
무엇이 당신의 질문입니까? 결과? "연결 (nam, SIGNAL (finished (QNetworkReply *)), this, SLOT (GetUserDataCompleted (QNetworkReply *)));" GetUserData() 및 GetMessages() 안에 있습니까? 또는 같은 기능 안에서? –
해당 없음 MainWindow 생성자 안에 있습니다. 업데이트 된 질문보기 – user525717
예상되는 결과는 무엇입니까? 그리고 현재의 결과는 무엇입니까? Btw, 두 번 연결할 필요는 없습니다. 하나이면 충분합니다. 그러나 결과에 영향을주지 않습니다. –