How to send a DELETE request Using QNetworkAccessManager?
Asked Answered
A

1

7

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 e.g name?

Almost answered 4/2, 2014 at 9:51 Comment(0)
F
10

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

Fowling answered 4/2, 2014 at 19:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.