<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # QIODevice Class Reference ## [[QtCore](index.htm) module] The QIODevice class is the base interface class of all I/O devices in Qt. [More...](#details) 繼承[QObject](qobject.html)。 通過繼承[QAbstractSocket](qabstractsocket.html),[QBuffer](qbuffer.html),[QFile](qfile.html),[QLocalSocket](qlocalsocket.html),[QNetworkReply](qnetworkreply.html)和[QProcess](qprocess.html)。 ### Types * `class **[OpenMode](index.htm)**` * `enum OpenModeFlag { NotOpen, ReadOnly, WriteOnly, ReadWrite, ..., Unbuffered }` ### Methods * `__init__ (self)` * `__init__ (self, QObject?parent)` * `bool atEnd (self)` * `int bytesAvailable (self)` * `int bytesToWrite (self)` * `bool canReadLine (self)` * `close (self)` * `QString errorString (self)` * `(bool, str?c) getChar (self)` * `bool isOpen (self)` * `bool isReadable (self)` * `bool isSequential (self)` * `bool isTextModeEnabled (self)` * `bool isWritable (self)` * `bool open (self, OpenMode?mode)` * `OpenMode openMode (self)` * `QByteArray peek (self, int?maxlen)` * `int pos (self)` * `bool putChar (self, str?c)` * `str read (self, int?maxlen)` * `QByteArray readAll (self)` * `str readData (self, int?maxlen)` * `str readLine (self, int?maxlen?=?0)` * `str readLineData (self, int?maxlen)` * `bool reset (self)` * `bool seek (self, int?pos)` * `setErrorString (self, QString?errorString)` * `setOpenMode (self, OpenMode?openMode)` * `setTextModeEnabled (self, bool?enabled)` * `int size (self)` * `ungetChar (self, str?c)` * `bool waitForBytesWritten (self, int?msecs)` * `bool waitForReadyRead (self, int?msecs)` * `int write (self, QByteArray?data)` * `int writeData (self, str?data)` ### Qt Signals * `void aboutToClose ()` * `void bytesWritten (qint64)` * `void readChannelFinished ()` * `void readyRead ()` * * * ## Detailed Description 該QIODevice中類是Qt中所有的I / O設備的基本接口類。 QIODevice中提供了一個通用的實現和抽象接口用于支持讀數據塊,寫裝置,如[QFile](qfile.html),[QBuffer](qbuffer.html)和[QTcpSocket](qtcpsocket.html)。 QIODevice中是抽象的,并且不能被實例化,但是通常使用它定義提供設備無關的I / O特性的接口。例如, Qt的XML類上的QIODevice指針操作,使他們能夠與各種設備(如文件和緩沖區)使用。 訪問該設備之前,[open](qiodevice.html#open)( )必須被調用來設置正確的[OpenMode](qiodevice.html#OpenModeFlag-enum)(如[ReadOnly](qiodevice.html#OpenModeFlag-enum) or [ReadWrite](qiodevice.html#OpenModeFlag-enum)) 。然后,您可以寫信給裝置[write](qiodevice.html#write)()或[putChar](qiodevice.html#putChar)( ) ,并宣讀通過調用[read](qiodevice.html#read)( )[readLine](qiodevice.html#readLine)() ,或[readAll](qiodevice.html#readAll)( ) 。通話[close](qiodevice.html#close)()當你的設備完成的。 隨機存取設備和順序裝置:兩種類型的設備之間的QIODevice區分。 * Random-access devices support seeking to arbitrary positions using [seek](qiodevice.html#seek)(). The current position in the file is available by calling [pos](qiodevice.html#pos)(). [QFile](qfile.html) and [QBuffer](qbuffer.html) are examples of random-access devices. * Sequential devices don't support seeking to arbitrary positions. The data must be read in one pass. The functions [pos](qiodevice.html#pos)() and [size](qiodevice.html#size)() don't work for sequential devices. [QTcpSocket](qtcpsocket.html) and [QProcess](qprocess.html) are examples of sequential devices. 您可以使用[isSequential](qiodevice.html#isSequential)()來確定設備的類型。 QIODevice中發出[readyRead](qiodevice.html#readyRead)( )當新的數據可供讀取,例如,如果新數據到達網絡上,或者額外的數據附加到正在讀取的文件。您可以致電[bytesAvailable](qiodevice.html#bytesAvailable)( )來確定當前可用來讀取的字節數。這是常見的使用[bytesAvailable](qiodevice.html#bytesAvailable)()連同[readyRead](qiodevice.html#readyRead)()信號與異步設備,如編程[QTcpSocket](qtcpsocket.html)其中數據的片段可以在時間的任意時刻到達。 QIODevice中放出[bytesWritten](qiodevice.html#bytesWritten)()信號的每一個數據的有效載荷中已被寫入到該設備的時間。使用[bytesToWrite](qiodevice.html#bytesToWrite)()來確定數據等待寫入的電流量。 QIODevice中的某些亞類,如[QTcpSocket](qtcpsocket.html)和[QProcess](qprocess.html),是異步的。這意味著, I / O功能,如[write](qiodevice.html#write)()或[read](qiodevice.html#read)( )總是立刻返回,而當控制返回到事件循環與設備本身的通信可能發生。 QIODevice中提供的功能,讓您可以強制這些操作必須立即執行的,而阻塞調用線程,并沒有進入事件循環。這允許用戶在沒有事件循環,或者在單獨的線程中使用的QIODevice子類: * [waitForReadyRead](qiodevice.html#waitForReadyRead)() - This function suspends operation in the calling thread until new data is available for reading. * [waitForBytesWritten](qiodevice.html#waitForBytesWritten)() - This function suspends operation in the calling thread until one payload of data has been written to the device. * waitFor....() - Subclasses of QIODevice implement blocking functions for device-specific operations. For example, [QProcess](qprocess.html) has a function called waitForStarted() which suspends operation in the calling thread until the process has started. 從主, GUI線程中調用這些功能,可能會導致你的用戶界面凍結。例如: ``` [QProcess](qprocess.html) gzip; gzip.start("gzip", [QStringList](qstringlist.html)() << "-c"); if (!gzip.waitForStarted()) return false; gzip.write("uncompressed data"); [QByteArray](qbytearray.html) compressed; while (gzip.waitForReadyRead()) compressed += gzip.readAll(); ``` 通過子類QIODevice中,您可以提供相同的接口,以你自己的I / O設備。 QIODevice中的子類來實現保護時,才需要[readData](qiodevice.html#readData)()和[writeData](qiodevice.html#writeData)()函數。 QIODevice中使用這些函數執行所有它的便利功能,如[getChar](qiodevice.html#getChar)( )[readLine](qiodevice.html#readLine)()和[write](qiodevice.html#write)( ) 。 QIODevice中還為您處理訪問控制,這樣你就可以安全地假定該設備在寫模式打開,如果[writeData](qiodevice.html#writeData)()被調用。 一些子類,如[QFile](qfile.html)和[QTcpSocket](qtcpsocket.html),使用的內存緩沖區用于數據的中間存儲實現。這減少了所需的設備訪問調用,這通常是非常慢的數量。使緩沖功能,如[getChar](qiodevice.html#getChar)()和[putChar](qiodevice.html#putChar)()快,因為它們可以在設備本身上的存儲器緩沖操作,而不是直接。某些I / O操作,但是,不具有緩沖工作。例如,如果多個用戶打開相同的設備和由字符閱讀的字符,它們最終可能讀取相同的數據時,為了讀取一個單獨的組塊的每個。出于這個原因, QIODevice中允許你通過將無緩沖標志來繞過任何緩沖[open](qiodevice.html#open)( ) 。當繼承了QIODevice ,記得要繞過你可以使用時,設備處于無緩沖模式打開的任何緩沖區。 * * * ## Type Documentation ``` QIODevice.OpenModeFlag ``` 此枚舉是使用[open](qiodevice.html#open)( )來描述,其中一個裝置被打開的模式。它也被返回[openMode](qiodevice.html#openMode)( ) 。 | Constant | Value | Description | | --- | --- | --- | | `QIODevice.NotOpen` | `0x0000` | 該設備未打開。 | | `QIODevice.ReadOnly` | `0x0001` | 該設備是開放式的閱讀。 | | `QIODevice.WriteOnly` | `0x0002` | 該設備是開放式的寫作。 | | `QIODevice.ReadWrite` | `ReadOnly &#124; WriteOnly` | 該設備是開放式的閱讀和寫作。 | | `QIODevice.Append` | `0x0004` | 該器件采用追加模式打開,讓所有的數據寫入到文件的末尾。 | | `QIODevice.Truncate` | `0x0008` | 如果可能的話,該裝置被打開之前被截斷。該設備的所有早期的內容會丟失。 | | `QIODevice.Text` | `0x0010` | 閱讀時,行尾的終結被翻譯成的'\ n ' 。寫作時,行尾的終結將被轉換為本地編碼,例如' \ r \ ?'為Win32 。 | | `QIODevice.Unbuffered` | `0x0020` | 任何緩沖設備中被繞過。 | 某些標志,如`Unbuffered`和`Truncate`一些子類中使用時,是沒有意義的。其中的一些限制是由器件的是由子類所表示的類型暗示。在其他情況下,該限制可能是由于在實施方式中,或者可以通過對底層平臺的罰款;例如[QTcpSocket](qtcpsocket.html)不支持`Unbuffered`模式,和本機API中的限制阻止[QFile](qfile.html)從支持`Unbuffered`在Windows上。 為openMode類型是一個typedef為[QFlags](index.htm)\u003cOpenModeFlag\u003e 。它存儲OpenModeFlag值的或組合。 * * * ## Method Documentation ``` QIODevice.__init__ (self) ``` 構造一個[QIODevice](qiodevice.html)對象。 ``` QIODevice.__init__ (self, QObject?parent) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 構造一個[QIODevice](qiodevice.html)與給定對象_parent_。 ``` bool QIODevice.atEnd (self) ``` 返回True如果當前讀寫位置是在設備上(即沒有可用于讀取設備上沒有更多的數據)的末尾,否則返回False 。 對于某些設備,了atEnd ( )可以返回True ,即使有更多的數據讀取。這種特殊的情況下只適用于產生直接回應你打電話數據設備[read](qiodevice.html#read)( )(例如,`/dev` or `/proc`在Unix和Mac OS X的文件,或者控制臺輸入/`stdin`在所有平臺) 。 **See also** [bytesAvailable](qiodevice.html#bytesAvailable)( )[read](qiodevice.html#read)()和[isSequential](qiodevice.html#isSequential)( ) 。 ``` int QIODevice.bytesAvailable (self) ``` 返回可用于讀出的字節數。這個函數是常用的使用順序的設備,以確定的字節數讀數之前在緩沖器中分配。 即重新實現這個函數的子類必須調用為了基實現,以包括QIODevices '緩沖區的大小。例如: ``` [long](index.htm#qint64-typedef) CustomDevice.bytesAvailable() const { return buffer.size() + [QIODevice](qiodevice.html).bytesAvailable(); } ``` **See also** [bytesToWrite](qiodevice.html#bytesToWrite)( )[readyRead](qiodevice.html#readyRead)()和[isSequential](qiodevice.html#isSequential)( ) 。 ``` int QIODevice.bytesToWrite (self) ``` 對于緩沖裝置,該函數返回字節等待寫入的數量。對于沒有緩沖裝置,該函數返回0 。 **See also** [bytesAvailable](qiodevice.html#bytesAvailable)( )[bytesWritten](qiodevice.html#bytesWritten)()和[isSequential](qiodevice.html#isSequential)( ) 。 ``` bool QIODevice.canReadLine (self) ``` 返回True如果一個完整的數據線可以從設備中讀取,否則返回False 。 需要注意的是緩沖裝置,這也沒有辦法確定哪些可以讀取,總是返回False 。 這個功能通常被稱為與結合[readyRead](qiodevice.html#readyRead)()信號。 即重新實現這個函數的子類必須調用基實現,以包括的內容[QIODevice](qiodevice.html)的緩沖。例如: ``` bool CustomDevice.canReadLine() const { return buffer.contains('\n') || [QIODevice](qiodevice.html).canReadLine(); } ``` **See also** [readyRead](qiodevice.html#readyRead)()和[readLine](qiodevice.html#readLine)( ) 。 ``` QIODevice.close (self) ``` 首先發出[aboutToClose](qiodevice.html#aboutToClose)() ,然后關閉該裝置,并將其[OpenMode](qiodevice.html#OpenModeFlag-enum)至[NotOpen](qiodevice.html#OpenModeFlag-enum)。錯誤字符串也被重置。 **See also** [setOpenMode](qiodevice.html#setOpenMode)()和[OpenMode](qiodevice.html#OpenModeFlag-enum)。 ``` QString QIODevice.errorString (self) ``` 返回上次發生設備錯誤的人類可讀的描述。 **See also** [setErrorString](qiodevice.html#setErrorString)( ) 。 ``` (bool, str?c) QIODevice.getChar (self) ``` 讀取從設備并將其存儲在一個字符_c_。如果_c_是0時,字符被丟棄。成功時返回TRUE ,否則返回False 。 **See also** [read](qiodevice.html#read)( )[putChar](qiodevice.html#putChar)()和[ungetChar](qiodevice.html#ungetChar)( ) 。 ``` bool QIODevice.isOpen (self) ``` 返回True如果該設備已打開,否則返回False 。設備是開放的,如果它可以讀取和/或寫入。默認情況下,這個函數返回False ,如果[openMode](qiodevice.html#openMode)()返回`NotOpen`。 **See also** [openMode](qiodevice.html#openMode)()和[OpenMode](qiodevice.html#OpenModeFlag-enum)。 ``` bool QIODevice.isReadable (self) ``` 返回True如果數據可以從設備讀取,否則返回False 。使用[bytesAvailable](qiodevice.html#bytesAvailable)()來確定多少字節可以被讀取。 這是一個方便的功能,如果它檢查[OpenMode](qiodevice.html#OpenModeFlag-enum)該裝置包含[ReadOnly](qiodevice.html#OpenModeFlag-enum)標志。 **See also** [openMode](qiodevice.html#openMode)()和[OpenMode](qiodevice.html#OpenModeFlag-enum)。 ``` bool QIODevice.isSequential (self) ``` 返回True如果該設備是連續的,否則返回False 。 連續的設備,而不是一個隨機存取設備,還沒有任何概念的一個開始,結束,大小,或當前位置,并且它們不支持尋求。您只能從設備讀取時,它報告的數據是可用的。順序設備的最常見的例子是網絡套接字。在Unix上,特殊文件如/ dev / zero的和FIFO管道是連續的。 常規文件,另一方面,也支持隨機訪問。它們既具有大小和當前位置,并且它們還支持尋求向后和向前的數據流中。普通文件是不連續的。 該[QIODevice](qiodevice.html)實現返回False 。 **See also** [bytesAvailable](qiodevice.html#bytesAvailable)( ) 。 ``` bool QIODevice.isTextModeEnabled (self) ``` 返回True如果[Text](qiodevice.html#OpenModeFlag-enum)標志為啟用,否則返回False 。 **See also** [setTextModeEnabled](qiodevice.html#setTextModeEnabled)( ) 。 ``` bool QIODevice.isWritable (self) ``` 返回True如果數據可以被寫入到該設備,否則返回False 。 這是一個方便的功能,如果它檢查[OpenMode](qiodevice.html#OpenModeFlag-enum)該裝置包含[WriteOnly](qiodevice.html#OpenModeFlag-enum)標志。 **See also** [openMode](qiodevice.html#openMode)()和[OpenMode](qiodevice.html#OpenModeFlag-enum)。 ``` bool QIODevice.open (self, OpenMode?mode) ``` 打開該設備,并將其[OpenMode](qiodevice.html#OpenModeFlag-enum)至_mode_。成功返回True ,否則返回False 。這個函數應該被稱為從open()或其他函數打開設備的任何重新實現。 **See also** [openMode](qiodevice.html#openMode)()和[OpenMode](qiodevice.html#OpenModeFlag-enum)。 ``` OpenMode QIODevice.openMode (self) ``` [](index.htm) [返回在該設備已被打開的模式,即](index.htm)[ReadOnly](qiodevice.html#OpenModeFlag-enum) or [WriteOnly](qiodevice.html#OpenModeFlag-enum)。 **See also** [setOpenMode](qiodevice.html#setOpenMode)()和[OpenMode](qiodevice.html#OpenModeFlag-enum)。 ``` QByteArray QIODevice.peek (self, int?maxlen) ``` [](qbytearray.html) [閱讀次數最多_maxSize_從設備到字節_data_,無副作用(即,如果你調用](qbytearray.html)[read](qiodevice.html#read)( ) PEEK ()之后,您將獲得相同的數據) 。返回讀取的字節數。如果發生錯誤,企圖偷看在打開設備時,如[WriteOnly](qiodevice.html#OpenModeFlag-enum)模式下,該函數返回-1 。 當沒有更多的數據可供讀取返回0。 例如: ``` bool isExeFile([QFile](qfile.html) *file) { char buf[2]; if (file->peek(buf, sizeof(buf)) == sizeof(buf)) return (buf[0] == 'M' && buf[1] == 'Z'); return false; } ``` 這個函數是Qt 4.1中引入。 **See also** [read](qiodevice.html#read)( ) 。 ``` int QIODevice.pos (self) ``` 對于隨機存取設備,此函數返回的數據被寫入或讀出的位置。對于順序裝置或封閉裝置,其中有一個“當前位置”的概念,則返回0 。 該設備的當前讀/寫位置在內部保持由[QIODevice](qiodevice.html),所以重新實現這個功能是沒有必要的。當子類[QIODevice](qiodevice.html),使用[QIODevice.seek](qiodevice.html#seek)( )通知[QIODevice](qiodevice.html)的變化在設備中的位置。 **See also** [isSequential](qiodevice.html#isSequential)()和[seek](qiodevice.html#seek)( ) 。 ``` bool QIODevice.putChar (self, str?c) ``` 寫入字符_c_到設備。成功時返回TRUE ,否則返回False 。 **See also** [write](qiodevice.html#write)( )[getChar](qiodevice.html#getChar)()和[ungetChar](qiodevice.html#ungetChar)( ) 。 ``` str QIODevice.read (self, int?maxlen) ``` 閱讀次數最多_maxSize_從設備到字節_data_,并返回讀取的字節數。如果發生錯誤,則嘗試從在打開的設備來讀取時,如[WriteOnly](qiodevice.html#OpenModeFlag-enum)模式下,該函數返回-1 。 當沒有更多的數據可供讀取返回0。不過,過去讀的流的末尾被認為是一個錯誤,所以這個函數返回-1在這種情況下(即,讀一個已關閉的套接字或之后的過程已經去世) 。 **See also** [readData](qiodevice.html#readData)( )[readLine](qiodevice.html#readLine)()和[write](qiodevice.html#write)( ) 。 ``` QByteArray QIODevice.readAll (self) ``` [ 這是一個重載函數。 ](qbytearray.html) [從設備上讀取所有可用的數據,并將其作為一個](qbytearray.html)[QByteArray](qbytearray.html)。 此函數沒有辦法報告錯誤;返回一個空QByteArray中( )可能意味著要么沒有數據是目前可用于閱讀,或發生了錯誤。 ``` str QIODevice.readData (self, int?maxlen) ``` 這種方法是抽象的,應在任何子類中重新實現。 讀取高達_maxSize_從設備到字節_data_,并返回讀取的字節數或-1,如果發生了錯誤。 如果沒有字節被讀取并永遠不會有更多可用的字節(例子包括插座關閉,管道關閉,子進程結束) ,該函數返回-1 。 調用此函數由[QIODevice](qiodevice.html)。創建的子類時重新實現此功能[QIODevice](qiodevice.html)。 當重新實現這個功能是很重要的,這個函數讀取所有需要的數據,然后返回。這是必需的,以便[QDataStream](qdatastream.html)要能夠對類進行操作。[QDataStream](qdatastream.html)假設所有請求的信息被讀取,因此不會重試閱讀,如果有問題。 **See also** [read](qiodevice.html#read)( )[readLine](qiodevice.html#readLine)()和[writeData](qiodevice.html#writeData)( ) 。 ``` str QIODevice.readLine (self, int?maxlen?=?0) ``` 該函數讀取一行的從設備的ASCII字符,最多的_maxSize_ - 1個字節,存儲在字符_data_,并返回讀取的字節數。如果某行不能被讀取,但沒有錯誤發生,則該函數返回0 。如果發生錯誤,此函數返回什么可以讀取的長度,或-1,如果沒有被讀取。 一個終端'\ 0'字節總是附加到_data_,所以_maxSize_必須大于1。 數據被讀取,直到下列任一條件滿足: * The first '\n' character is read. * _maxSize_ - 1 bytes are read. * The end of the device data is detected. 例如,下面的代碼讀取一行從文件中的字符: ``` [QFile](qfile.html) file("box.txt"); if (file.open([QFile](qfile.html).ReadOnly)) { char buf[1024]; [long](index.htm#qint64-typedef) lineLength = file.readLine(buf, sizeof(buf)); if (lineLength != -1) { // the line is available in buf } } ``` 換行符( '\ n')時包含在緩沖區中。如果一個換行符MAXSIZE之前沒有遇到過 - 1字節被讀取,換行不會被插入到緩沖區。在windows換行符替換為'\ n ' 。 此函數調用[readLineData](qiodevice.html#readLineData)( ) ,這是使用重復調用實現[getChar](qiodevice.html#getChar)( ) 。您可以通過重新實現提供更有效的實現[readLineData](qiodevice.html#readLineData)( )在自己的子類。 **See also** [getChar](qiodevice.html#getChar)( )[read](qiodevice.html#read)()和[write](qiodevice.html#write)( ) 。 ``` str QIODevice.readLineData (self, int?maxlen) ``` 讀取高達_maxSize_字符轉換成_data_并返回讀取的字符數。 調用此函數由[readLine](qiodevice.html#readLine)( ) ,并提供了其基本的實現,用[getChar](qiodevice.html#getChar)( ) 。緩沖裝置可改善性能[readLine](qiodevice.html#readLine)( )通過重新實現此功能。 [readLine](qiodevice.html#readLine)( )添加一個'\ 0'字節_data_; readLineData ( )并不需要這樣做。 如果你重新實現這個功能,要小心返回正確的值:它應該返回讀取此行的字節數,包括終止換行符,或者0,如果沒有行被讀取了這一點。如果發生錯誤,它應該返回-1 ,當且僅當沒有字節被讀取。閱讀過去的EOF被認為是一個錯誤。 ``` bool QIODevice.reset (self) ``` 搜索到輸入的開始隨機訪問設備。成功時返回TRUE ,否則返回False (例如,如果設備沒有打開) 。 使用時需要注意的是一[QTextStream](qtextstream.html)上一個[QFile](qfile.html),在調用復位( )[QFile](qfile.html)不會有預期的結果,因為[QTextStream](qtextstream.html)緩沖文件。使用[QTextStream.seek](qtextstream.html#seek)( )函數來代替。 **See also** [seek](qiodevice.html#seek)( ) 。 ``` bool QIODevice.seek (self, int?pos) ``` 對于隨機存取設備,此函數設置當前位置_pos_,返回True表示成功,或False,如果發生了錯誤。對于順序的設備,默認的行為是什么都不做,返回False 。 當子類[QIODevice](qiodevice.html),你必須調用QIODevice.seek ( )在你的函數的開頭,以確保與誠信[QIODevice](qiodevice.html)的內置緩沖。基實現總是返回True 。 **See also** [pos](qiodevice.html#pos)()和[isSequential](qiodevice.html#isSequential)( ) 。 ``` QIODevice.setErrorString (self, QString?errorString) ``` 設置發生在最后一個設備錯誤的可讀描述_str_。 **See also** [errorString](qiodevice.html#errorString)( ) 。 ``` QIODevice.setOpenMode (self, OpenMode?openMode) ``` 設置[OpenMode](qiodevice.html#OpenModeFlag-enum)該設備的_openMode_。調用此函數來設置開放模式,如果該設備已被打開后旗更改。 **See also** [openMode](qiodevice.html#openMode)()和[OpenMode](qiodevice.html#OpenModeFlag-enum)。 ``` QIODevice.setTextModeEnabled (self, bool?enabled) ``` If _enabled_誠然,這個功能設置[Text](qiodevice.html#OpenModeFlag-enum)標志裝置上,否則[Text](qiodevice.html#OpenModeFlag-enum)標志被清除。此功能對于提供定制行尾類的處理上很有用[QIODevice](qiodevice.html)。 IO設備應調用此函數之前被打開。 **See also** [isTextModeEnabled](qiodevice.html#isTextModeEnabled)( )[open](qiodevice.html#open)()和[setOpenMode](qiodevice.html#setOpenMode)( ) 。 ``` int QIODevice.size (self) ``` 為開放的隨機存取設備,則該函數返回該裝置的尺寸。對于打開的順序設備,[bytesAvailable](qiodevice.html#bytesAvailable)( )返回。 如果設備被關閉,返回的大小不會反映設備的實際大小。 **See also** [isSequential](qiodevice.html#isSequential)()和[pos](qiodevice.html#pos)( ) 。 ``` QIODevice.ungetChar (self, str?c) ``` 把字符_c_返回到設備,并減少當前位置,除非該位置為0 。此功能通常被稱為“撤銷”一[getChar](qiodevice.html#getChar)()操作,記錄一個回溯解析器時,例如。 If _c_是不是從以前的設備讀取,行為是未定義的。 ``` bool QIODevice.waitForBytesWritten (self, int?msecs) ``` 用于緩沖的裝置,該函數將等待直到緩沖寫入的數據的有效載荷中已寫入的裝置和[bytesWritten](qiodevice.html#bytesWritten)()信號已被發出,或直到_msecs_毫秒過去了。如果毫秒為-1 ,此功能將不會超時。對于無緩沖裝置,它會立即返回。 返回True如果數據的有效載荷被寫入到設備,否則返回False (也就是說,如果操作超時,或者如果發生錯誤) 。 此功能可以操作沒有一個事件循環。編寫非GUI的應用程序和在非GUI線程執行I / O操作時,它是有用的。 如果從連接到一個時隙內的稱為[bytesWritten](qiodevice.html#bytesWritten)( )信號,[bytesWritten](qiodevice.html#bytesWritten)( )將不會被重新發射。 重新實現這個函數提供一個阻塞的API自定義設備。默認實現不執行任何操作,并返回False 。 **Warning:**從主(圖形用戶界面)線程調用該函數可能會導致你的用戶界面凍結。 **See also** [waitForReadyRead](qiodevice.html#waitForReadyRead)( ) 。 ``` bool QIODevice.waitForReadyRead (self, int?msecs) ``` 阻塞,直到新的數據可供讀取和[readyRead](qiodevice.html#readyRead)()信號已被發出,或直到_msecs_毫秒過去了。如果毫秒為-1 ,此功能將不會超時。 如果新的數據可供讀取,則返回True ,否則返回False (如果操作超時,或者如果發生錯誤) 。 此功能可以操作沒有一個事件循環。編寫非GUI的應用程序和在非GUI線程執行I / O操作時,它是有用的。 如果從連接到一個時隙內的稱為[readyRead](qiodevice.html#readyRead)( )信號,[readyRead](qiodevice.html#readyRead)( )將不會被重新發射。 重新實現這個函數提供一個阻塞的API自定義設備。默認實現不執行任何操作,并返回False 。 **Warning:**從主(圖形用戶界面)線程調用該函數可能會導致你的用戶界面凍結。 **See also** [waitForBytesWritten](qiodevice.html#waitForBytesWritten)( ) 。 ``` int QIODevice.write (self, QByteArray?data) ``` 寫在最_maxSize_數據從字節_data_到設備。返回實際寫入的,或者-1如果發生錯誤的字節數。 **See also** [read](qiodevice.html#read)()和[writeData](qiodevice.html#writeData)( ) 。 ``` int QIODevice.writeData (self, str?data) ``` 這種方法是抽象的,應在任何子類中重新實現。 寫入速度達_maxSize_從字節_data_到設備。返回寫入的字節數,或-1,如果發生了錯誤。 調用此函數由[QIODevice](qiodevice.html)。創建的子類時重新實現此功能[QIODevice](qiodevice.html)。 當重新實現這個功能是很重要的,這個函數將所有可用的返回之前的數據。這是必需的,以便[QDataStream](qdatastream.html)要能夠對類進行操作。[QDataStream](qdatastream.html)假設所有的信息寫入,因此不會重試寫,如果有一個問題。 **See also** [read](qiodevice.html#read)()和[write](qiodevice.html#write)( ) 。 * * * ## Qt Signal Documentation ``` void aboutToClose () ``` 這是該信號的默認超載。 時,該設備在關閉這個信號被發射。如果您有需要裝置關閉之前執行(例如,如果你有數據需要被寫入到設備的單獨緩沖器)操作連接這個信號。 ``` void bytesWritten (qint64) ``` 這是該信號的默認超載。 每一數據的有效載荷已經被寫入到設備時,這個信號被發射。該_bytes_參數設置為寫在這個有效載荷的字節數。 bytesWritten ( )是不是遞歸發出,如果你重新進入事件循環或致電[waitForBytesWritten](qiodevice.html#waitForBytesWritten)()連接到bytesWritten一個時隙內()信號,該信號將不會再發射(盡管[waitForBytesWritten](qiodevice.html#waitForBytesWritten)( )可能仍然返回True ) 。 **See also** [readyRead](qiodevice.html#readyRead)( ) 。 ``` void readChannelFinished () ``` 這是該信號的默認超載。 當輸入(讀出)數據流在該裝置關閉時,這個信號被發射。它剛一閉幕時探測的發射,這意味著仍有可能適用于讀取數據[read](qiodevice.html#read)( ) 。 此功能被引入Qt的4.4 。 **See also** [atEnd](qiodevice.html#atEnd)()和[read](qiodevice.html#read)( ) 。 ``` void readyRead () ``` 這是該信號的默認超載。 每一次新的數據是可用于從設備中讀取這個信號被發射。它只會再次發出一次新的數據是可用的,比如當網絡數據的一個新的有效載荷已經到達您的網絡套接字,或者當一個新的數據塊是否已經被添加到您的設備。 的readyRead ( )是不是遞歸發出,如果你重新進入事件循環或致電[waitForReadyRead](qiodevice.html#waitForReadyRead)()連接到所述的readyRead一個時隙內()信號,該信號將不會再發射(盡管[waitForReadyRead](qiodevice.html#waitForReadyRead)( )可能仍然返回True ) 。 注意執行從派生類開發商[QIODevice](qiodevice.html):你應該總是散發出的readyRead ( )時,新的數據已經到達(不散發這不僅是因為有數據仍然可以讀取你的緩沖區) 。不要發出的readyRead ( )在其他條件。 **See also** [bytesWritten](qiodevice.html#bytesWritten)( ) 。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看