Home

QNetworkReply

QNetworkReply is a class in the Qt Network module that represents the reply to a network request. It is produced by QNetworkAccessManager when performing an operation such as GET, POST, or others. The reply encapsulates the response data as well as metadata such as HTTP headers, status codes, and the request URL.

The reply object is created as part of the lifecycle of a network operation and is typically

Data access is provided through the streaming interface of QIODevice. You can read the response payload incrementally

Metadata and headers are accessible through various helpers. The reply exposes the original URL via url() and

Error handling and cancellation are supported through abort() to cancel an in-progress request and error reporting

consumed
by
the
application
after
the
corresponding
request
is
issued.
It
inherits
from
QObject
and
QIODevice,
allowing
event-driven
data
handling.
Common
signals
include
readyRead()
to
indicate
that
new
data
can
be
read,
finished()
when
the
operation
completes,
and
error
signals
to
report
failures.
The
specific
error
reporting
is
exposed
via
error()
or
errorString(),
depending
on
the
Qt
version
and
API
usage.
with
readData(),
or
retrieve
the
entire
content
with
readAll().
Important
convenience
methods
include
bytesAvailable()
and
isSequential(),
which
help
callers
manage
data
flow.
A
consumer
typically
connects
to
readyRead()
and
reads
data
as
it
becomes
available.
the
operation
type
via
operation().
Response
headers
can
be
queried
with
header(QNetworkRequest::KnownHeaders)
and
rawHeaderPairs(),
providing
both
known
and
raw
header
information.
Attributes
such
as
the
HTTP
status
code
and
reason
phrase
are
obtainable
via
attribute(),
using
known
attributes
like
HttpStatusCodeAttribute.
mechanisms
(NetworkError
enum
and
errorString()).
The
NetworkError
enum
covers
conditions
such
as
NoError,
ConnectionRefusedError,
RemoteHostClosedError,
TimeoutError,
and
others.
QNetworkReply
is
intended
to
be
used
in
conjunction
with
QNetworkAccessManager
and
is
typically
managed
by
deleting
the
object
after
finished,
often
via
deleteLater().