qurloperator.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 511 行 · 第 1/3 页

HTML
511
字号
<h3 class=fn>void <a name="connectionStateChanged"></a>QUrlOperator::connectionStateChanged ( int&nbsp;state, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;data )<tt> [signal]</tt></h3><p> This signal is emitted whenever the URL operator's connectionstate changes. <em>state</em> describes the new state, which is a<a href="qnetworkprotocol.html#ConnectionState-enum">QNetworkProtocol::ConnectionState</a> value.<p> <em>data</em> is a string that describes the change of the connection.This can be used to display a message to the user.<h3 class=fn><a href="qptrlist.html">QPtrList</a>&lt;QNetworkOperation&gt; <a name="copy"></a>QUrlOperator::copy ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;from, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;to, bool&nbsp;move = FALSE, bool&nbsp;toPath = TRUE )<tt> [virtual]</tt></h3>Copies the file <em>from</em> to <em>to</em>. If <em>move</em> is TRUE, the file ismoved (copied and removed). <em>from</em> must point to a file and <em>to</em>must point to a directory (into which <em>from</em> is copied) unless <em>toPath</em> is set to FALSE. If <em>toPath</em> is set to FALSE then the <em>to</em> variable is assumed to be the absolute file path (destinationfile path + file name). The copying is done using the <a href="#get">get</a>() and<a href="#put">put</a>() operations. If you want to be notified about the progress ofthe operation, connect to the <a href="#dataTransferProgress">dataTransferProgress</a>() signal. Bearin mind that the get() and put() operations emit this signalthrough the QUrlOperator. The number of transferred bytes and thetotal bytes that you receive as arguments in this signal do notrelate to the the whole copy operation; they relate first to theget() and then to the put() operation. Always check what type ofoperation the signal comes from; this is given in the signal'slast argument.<p> At the end, <a href="#finished">finished</a>() (with success or failure) is emitted, socheck the state of the network operation object to see whether ornot the operation was successful.<p> Because a move or copy operation consists of multiple operations(get(), put() and maybe <a href="#remove">remove</a>()), this function doesn't return asingle <a href="qnetworkoperation.html">QNetworkOperation</a>, but rather a list of them. They are inthe order: <a href="#get">get</a>(), <a href="#put">put</a>() and (if applicable) remove().<p> <p>See also <a href="#get">get</a>() and <a href="#put">put</a>().<h3 class=fn>void <a name="copy-2"></a>QUrlOperator::copy ( const&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp;&nbsp;files, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dest, bool&nbsp;move = FALSE )<tt> [virtual]</tt></h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Copies the <em>files</em> to the directory <em>dest</em>. If <em>move</em> is TRUEthe files are moved, not copied. <em>dest</em> must point to adirectory.<p> This function calls <a href="#copy">copy</a>() for each entry in <em>files</em> in turn. Youdon't get a result from this function; each time a new copybegins, <a href="#startedNextCopy">startedNextCopy</a>() is emitted, with a list ofQNetworkOperations that describe the new copy operation.<h3 class=fn>void <a name="createdDirectory"></a>QUrlOperator::createdDirectory ( const&nbsp;<a href="qurlinfo.html">QUrlInfo</a>&nbsp;&amp;&nbsp;i, <a href="qnetworkoperation.html">QNetworkOperation</a>&nbsp;*&nbsp;op )<tt> [signal]</tt></h3><p> This signal is emitted when <a href="#mkdir">mkdir</a>() succeeds and the directory hasbeen created. <em>i</em> holds the information about the new directory.<p> <em>op</em> is a pointer to the operation object, which contains all theinformation about the operation, including the state.<tt>op-&gt;arg(0)</tt> holds the new directory's name.<p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.<h3 class=fn>void <a name="data"></a>QUrlOperator::data ( const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;data, <a href="qnetworkoperation.html">QNetworkOperation</a>&nbsp;*&nbsp;op )<tt> [signal]</tt></h3><p> This signal is emitted when new <em>data</em> has been received after calling<a href="#get">get</a>() or <a href="#put">put</a>().<em>op</em> is a pointer to the operation object which contains allthe information about the operation, including the state.<tt>op-&gt;arg(0)</tt> holds the name of the file whose data is retrievedand op->rawArg(1) holds the (raw) data.<p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.<h3 class=fn>void <a name="dataTransferProgress"></a>QUrlOperator::dataTransferProgress ( int&nbsp;bytesDone, int&nbsp;bytesTotal, <a href="qnetworkoperation.html">QNetworkOperation</a>&nbsp;*&nbsp;op )<tt> [signal]</tt></h3><p> This signal is emitted during data transfer (using <a href="#put">put</a>() or<a href="#get">get</a>()). <em>bytesDone</em> specifies how many bytes of <em>bytesTotal</em> havebeen transferred. More information about the operation is stored in<em>op</em>, a pointer to the network operation that is processed.<em>bytesTotal</em> may be -1, which means that the total number of bytesis not known.<p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.<h3 class=fn>void <a name="deleteNetworkProtocol"></a>QUrlOperator::deleteNetworkProtocol ()<tt> [protected]</tt></h3>Deletes the currently used network protocol.<h3 class=fn>void <a name="finished"></a>QUrlOperator::finished ( <a href="qnetworkoperation.html">QNetworkOperation</a>&nbsp;*&nbsp;op )<tt> [signal]</tt></h3><p> This signal is emitted when an operation of some sort finishes,whether with success or failure. <em>op</em> is a pointer to theoperation object, which contains all the information, includingthe state, of the operation which has been finished. Check thestate and error code of the operation object to see whether or notthe operation was successful.<p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.<h3 class=fn>const&nbsp;<a href="qnetworkoperation.html">QNetworkOperation</a>&nbsp;* <a name="get"></a>QUrlOperator::get ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;location = QString::null )<tt> [virtual]</tt></h3>Tells the network protocol to get data from <em>location</em> or, ifthis is <a href="qstring.html#QString-null">QString::null</a>, to get data from the location to which thisURL points (see <a href="qurl.html#fileName">QUrl::fileName</a>() and <a href="qurl.html#encodedPathAndQuery">QUrl::encodedPathAndQuery</a>()).What happens then depends on the network protocol. The <a href="#data">data</a>()signal is emitted when data comes in. Because it's unlikely thatall data will come in at once, it is common for multiple data()signals to be emitted. The <a href="#dataTransferProgress">dataTransferProgress</a>() signal isemitted while processing the operation. At the end, <a href="#finished">finished</a>()(with success or failure) is emitted, so check the state of thenetwork operation object to see whether or not the operation wassuccessful.<p> If <em>location</em> is QString::null, the path of this QUrlOperatorshould point to a file when you use this operation. If <em>location</em>is not empty, it can be a relative URL (a child of the path towhich the QUrlOperator points) or an absolute URL.<p> For example, to get a web page you might do something like this:<p> <pre>    QUrlOperator op( "http://www.whatever.org/cgi-bin/search.pl?cmd=Hello" );    op.<a href="#get">get</a>();    </pre> <p> For most other operations, the path of the QUrlOperator must pointto a directory. If you want to download a file you could do thefollowing:<p> <pre>    QUrlOperator op( "ftp://ftp.whatever.org/pub" );    // do some other stuff like op.<a href="#listChildren">listChildren</a>() or op.<a href="#mkdir">mkdir</a>( "new_dir" )    op.<a href="#get">get</a>( "a_file.txt" );    </pre> <p> This will get the data of ftp://ftp.whatever.org/pub/a_file.txt.<p> <em>Never</em> do anything like this:<pre>    QUrlOperator op( "http://www.whatever.org/cgi-bin" );    op.<a href="#get">get</a>( "search.pl?cmd=Hello" ); // WRONG!    </pre> <p> If <em>location</em> is not empty and relative it must not contain anyqueries or references, just the name of a child. So if you need tospecify a query or reference, do it as shown in the first exampleor specify the full URL (such ashttp://www.whatever.org/cgi-bin/search.pl?cmd=Hello) as <em>location</em>.<p> <p>See also <a href="#copy">copy</a>().<h3 class=fn>void <a name="getNetworkProtocol"></a>QUrlOperator::getNetworkProtocol ()<tt> [protected]</tt></h3>Finds a network protocol for the URL and deletes the old network protocol.<h3 class=fn><a href="qurlinfo.html">QUrlInfo</a> <a name="info"></a>QUrlOperator::info ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;entry ) const<tt> [virtual]</tt></h3>Returns the URL information for the child <em>entry</em>, or returns anempty <a href="qurlinfo.html">QUrlInfo</a> object if there is no information available about<em>entry</em>.<h3 class=fn>bool <a name="isDir"></a>QUrlOperator::isDir ( bool&nbsp;*&nbsp;ok = 0 )<tt> [virtual]</tt></h3>Returns TRUE if the URL is a directory; otherwise returns FALSE.This may not always work correctly, if the protocol of the URL issomething other than file (local filesystem). If you pass a boolpointer as the <em>ok</em> argument, <em>*ok</em> is set to TRUE if the resultof this function is known to be correct, and to FALSE otherwise.<h3 class=fn>void <a name="itemChanged"></a>QUrlOperator::itemChanged ( <a href="qnetworkoperation.html">QNetworkOperation</a>&nbsp;*&nbsp;op )<tt> [signal]</tt></h3><p> This signal is emitted whenever a file which is a child of the URLhas been changed, for example by successfully calling <a href="#rename">rename</a>().<em>op</em> is a pointer to the operation object which contains all theinformation about the operation, including the state.<tt>op-&gt;arg(0)</tt> holds the original file name and <tt>op-&gt;arg(1)</tt> holdsthe new file name (if it was changed).<p> <p>See also <a href="qnetworkoperation.html">QNetworkOperation</a> and <a href="qnetworkprotocol.html">QNetworkProtocol</a>.<h3 class=fn>const&nbsp;<a href="qnetworkoperation.html">QNetworkOperation</a>&nbsp;* <a name="listChildren"></a>QUrlOperator::listChildren ()<tt> [virtual]</tt></h3>Starts listing the children of this URL (e.g. the files in thedirectory). The <a href="#start">start</a>() signal is emitted before the first entry

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?