简体   繁体   中英

How to send a DELETE request Using QNetworkAccessManager?

I am using QNetworkAccessManager to POST, PUT, and GET data from the server. The code looks like below.

QNetworkAccessManager *manager = new QNetworkAccessManager(this);

connect(manager, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)), 
  SLOT(slotProxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)));
connect(manager, SIGNAL(authenticationRequired(QNetworkReply *, QAuthenticator *)), 
  SLOT(slotAuthenticationRequired(QNetworkReply *, QAuthenticator *)));

QNetworkRequest request;

request.setUrl(m_url);
request.setRawHeader("User-Agent", "Qt NetworkAccess 1.3");

m_pReply = manager->get(request);
m_pReply = manager->post(request,"name=someName");
m_pReply = manager->put(request,"name=someName");

I am Not able to find any delete methods for the request .Yes I found manager->deleteResource(request)

But is there any

manager->delete(request,"name=someName")

method in Qt? Or is there any other method for deleting the data on the basis of eg name?

Since delete is a reserved word in C++, the corresponding method of QNetworkAccessManager is called deleteResource .

http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkaccessmanager.html#deleteResource

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM