如何正确使用QNetworkReply?我见过这样的例子:
void HttpDownload::on_downloadButton_clicked()
{
// get url
url = (ui->urlEdit->text());
// get() method posts a request
// to obtain the contents of the target request
// and returns a new QNetworkReply object
// opened for reading which emits
// the readyRead() signal whenever new data arrives.
reply = manager->get(QNetworkRequest(url));
// Whenever more data is received from the network,
// this readyRead() signal is emitted
connect(reply, SIGNAL(finished()),
this, SLOT(handleFinish()));
}
在构建连接之前是否可能发出完成的信号?
答案 0 :(得分:0)
检查错误
.draw {
position: relative;
width: 400px;
height: 400px;
border: 1px #ccc dashed;
}
.draw div { position: absolute; }
.draw div[class^="h"] {
height: 20%;
width: 100%;
left: 0;
background: #d8d8d8;
}
.draw div[class^="v"] {
height: 100%;
width: 20%;
top: 0;
background: #212121;
}
.draw .h1 { top : 20%; }
.draw .h2 { top : 60%; }
.draw .v1 { left : 20%; }
.draw .v2 { left : 60%; }
.draw .v1:before {
position: inherit;
z-index: 2;
top: 20%;
left: 0;
width: 100%;
height: 20%;
content: "";
background: inherit;
}
我认为在错误情况下也会发出完成的信号,并且在建立连接之前它可能看起来像已完成。
答案 1 :(得分:0)
当然可以。一旦连接不再继续,就会发出finished
信号,并且不再发出任何信号。信号的意思是,基本上"我完成了发射信号,我的状态现在已经设定了#34;。任何不可恢复的错误条件必然会以finished
信号的发射结束。