返回介绍

QNetworkOperation Class

发布于 2019-10-04 15:01:46 字数 5787 浏览 893 评论 0 收藏 0

The QNetworkOperation class provides common operations for network protocols. More...

#include <qnetworkprotocol.h>

Inherits QObject.

List of all member functions.

Public Members

  • QNetworkOperation ( QNetworkProtocol::Operationoperation, constQString&arg0, constQString&arg1, constQString&arg2 )
  • QNetworkOperation ( QNetworkProtocol::Operationoperation, constQByteArray&arg0, constQByteArray&arg1, constQByteArray&arg2 )
  • ~QNetworkOperation ()
  • void setState ( QNetworkProtocol::Statestate )
  • void setProtocolDetail ( constQString&detail )
  • void setErrorCode ( intec )
  • void setArg ( intnum, constQString&arg )
  • void setRawArg ( intnum, constQByteArray&arg )
  • QNetworkProtocol::Operation operation () const
  • QNetworkProtocol::State state () const
  • QString arg ( intnum ) const
  • QByteArray rawArg ( intnum ) const
  • QString protocolDetail () const
  • int errorCode () const
  • void free ()

Detailed Description

The QNetworkOperation class provides common operations for network protocols.

An object is created to describe the operation and the current state for each operation that a network protocol should process.

For a detailed description of the Qt Network Architecture and how to implement and use network protocols in Qt, see the Qt Network Documentation.

See also QNetworkProtocol and Input/Output and Networking.


Member Function Documentation

QNetworkOperation::QNetworkOperation ( QNetworkProtocol::Operationoperation, constQString&arg0, constQString&arg1, constQString&arg2 )

Constructs a network operation object. operation is the type of the operation, and arg0, arg1 and arg2 are the first three arguments of the operation. The state is initialized to QNetworkProtocol::StWaiting.

See also QNetworkProtocol::Operation and QNetworkProtocol::State.

QNetworkOperation::QNetworkOperation ( QNetworkProtocol::Operationoperation, constQByteArray&arg0, constQByteArray&arg1, constQByteArray&arg2 )

Constructs a network operation object. operation is the type of the operation, and arg0, arg1 and arg2 are the first three raw data arguments of the operation. The state is initialized to QNetworkProtocol::StWaiting.

See also QNetworkProtocol::Operation and QNetworkProtocol::State.

QNetworkOperation::~QNetworkOperation ()

Destructor.

QString QNetworkOperation::arg ( intnum ) const

Returns the operation's num-th argument. If this argument was not already set, an empty string is returned.

Examples: network/ftpclient/ftpmainwindow.cpp and network/networkprotocol/nntp.cpp.

int QNetworkOperation::errorCode () const

Returns the error code for the last error that occurred.

Example: network/ftpclient/ftpmainwindow.cpp.

void QNetworkOperation::free ()

Sets this object to delete itself when it hasn't been used for one second.

Because QNetworkOperation pointers are passed around a lot the QNetworkProtocol generally does not have enough knowledge to delete these at the correct time. If a QNetworkProtocol doesn't need an operation any more it will call this function instead.

Note: you should never need to call the method yourself.

QNetworkProtocol::Operation QNetworkOperation::operation () const

Returns the type of the operation.

Example: network/ftpclient/ftpmainwindow.cpp.

QString QNetworkOperation::protocolDetail () const

Returns a detailed error message for the last error. This must have been set using setProtocolDetail().

Example: network/ftpclient/ftpmainwindow.cpp.

QByteArray QNetworkOperation::rawArg ( intnum ) const

Returns the operation's num-th raw data argument. If this argument was not already set, an empty bytearray is returned.

void QNetworkOperation::setArg ( intnum, constQString&arg )

Sets the network operation's num-th argument to arg.

void QNetworkOperation::setErrorCode ( intec )

Sets the error code to ec.

If the operation failed, the protocol should set an error code to describe the error in more detail. If possible, one of the error codes defined in QNetworkProtocol should be used.

See also setProtocolDetail() and QNetworkProtocol::Error.

void QNetworkOperation::setProtocolDetail ( constQString&detail )

If the operation failed, the error message can be specified as detail.

void QNetworkOperation::setRawArg ( intnum, constQByteArray&arg )

Sets the network operation's num-th raw data argument to arg.

void QNetworkOperation::setState ( QNetworkProtocol::Statestate )

Sets the state of the operation object. This should be done by the network protocol during processing; at the end it should be set to QNetworkProtocol::StDone or QNetworkProtocol::StFailed, depending on success or failure.

See also QNetworkProtocol::State.

QNetworkProtocol::State QNetworkOperation::state () const

Returns the state of the operation. You can determine whether an operation is still waiting to be processed, is being processed, has been processed successfully, or failed.

Example: network/ftpclient/ftpmainwindow.cpp.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文