⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qiodevice.3qt

📁 Trolltech公司发布的基于C++图形开发环境
💻 3QT
📖 第 1 页 / 共 2 页
字号:
'\" t.TH QIODevice 3qt "24 January 2005" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQIODevice \- The base class of I/O devices.br.PP\fC#include <qiodevice.h>\fR.PPInherited by QBuffer, QFile, QSocket and QSocketDevice..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQIODevice\fR () ".br.ti -1c.BI "virtual \fB~QIODevice\fR () ".br.ti -1c.BI "int \fBflags\fR () const".br.ti -1c.BI "int \fBmode\fR () const".br.ti -1c.BI "int \fBstate\fR () const".br.ti -1c.BI "bool \fBisDirectAccess\fR () const".br.ti -1c.BI "bool \fBisSequentialAccess\fR () const".br.ti -1c.BI "bool \fBisCombinedAccess\fR () const".br.ti -1c.BI "bool \fBisBuffered\fR () const".br.ti -1c.BI "bool \fBisRaw\fR () const".br.ti -1c.BI "bool \fBisSynchronous\fR () const".br.ti -1c.BI "bool \fBisAsynchronous\fR () const".br.ti -1c.BI "bool \fBisTranslated\fR () const".br.ti -1c.BI "bool \fBisReadable\fR () const".br.ti -1c.BI "bool \fBisWritable\fR () const".br.ti -1c.BI "bool \fBisReadWrite\fR () const".br.ti -1c.BI "bool \fBisInactive\fR () const".br.ti -1c.BI "bool \fBisOpen\fR () const".br.ti -1c.BI "int \fBstatus\fR () const".br.ti -1c.BI "void \fBresetStatus\fR () ".br.ti -1c.BI "virtual bool \fBopen\fR ( int mode ) ".br.ti -1c.BI "virtual void \fBclose\fR () ".br.ti -1c.BI "virtual void \fBflush\fR () ".br.ti -1c.BI "virtual uint \fBsize\fR () const".br.ti -1c.BI "virtual int \fBat\fR () const".br.ti -1c.BI "virtual bool \fBat\fR ( int ) ".br.ti -1c.BI "virtual bool \fBatEnd\fR () const".br.ti -1c.BI "bool \fBreset\fR () ".br.ti -1c.BI "virtual int \fBreadBlock\fR ( char * " "data" ", uint maxlen ) ".br.ti -1c.BI "virtual int \fBwriteBlock\fR ( const char * " "data" ", uint len ) ".br.ti -1c.BI "virtual int \fBreadLine\fR ( char * " "data" ", uint maxlen ) ".br.ti -1c.BI "int \fBwriteBlock\fR ( const QByteArray & data ) ".br.ti -1c.BI "QByteArray \fBreadAll\fR () ".br.ti -1c.BI "virtual int \fBgetch\fR () ".br.ti -1c.BI "virtual int \fBputch\fR ( int ) ".br.ti -1c.BI "virtual int \fBungetch\fR ( int ) ".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "void \fBsetFlags\fR ( int f ) (internal)".br.ti -1c.BI "void \fBsetType\fR ( int ) (internal)".br.ti -1c.BI "void \fBsetMode\fR ( int ) (internal)".br.ti -1c.BI "void \fBsetState\fR ( int ) (internal)".br.ti -1c.BI "void \fBsetStatus\fR ( int ) (internal)".br.in -1c.SH DESCRIPTIONThe QIODevice class is the base class of I/O devices..PPAn I/O device represents a medium that one can read bytes from and/or write bytes to. The QIODevice class is the abstract superclass of all such devices; classes like QFile, QBuffer and QSocket inherit QIODevice and implement virtual functions like write() appropriately..PPWhile applications sometimes use QIODevice directly, mostly it is better to go through QTextStream and QDataStream, which provide stream operations on any QIODevice subclass. QTextStream provides text-oriented stream functionality (for human-readable ASCII files, for example), while QDataStream deals with binary data in a totally platform-independent manner..PPThe public member functions in QIODevice roughly fall into two groups: The action functions and the state access functions. The most important action functions are: .TPopen() opens a device for reading and/or writing, depending on the argument to open()..TPclose() closes the device and tidies up..TPreadBlock() reads a block of data from the device..TPwriteBlock() writes a block of data to the device..TPreadLine() reads a line (of text, usually) from the device..TPflush() ensures that all buffered data are written to the real device..IPThere are also some other, less used, action functions: .TPgetch() reads a single character..TPungetch() forgets the last call to getch(), if possible..TPputch() writes a single character..TPsize() returns the size of the device, if there is one..TPat() returns the current read/write pointer, if there is one for this device, or it moves the pointer..TPatEnd() says whether there is more to read, if that is a meaningful question for this device..TPreset() moves the read/write pointer to the start of the device, if that is possible for this device..IPThe state access are all "get" functions. The QIODevice subclass calls setState() to update the state, and simple access functions tell the user of the device what the device's state is. Here are the settings, and their associated access functions: .TPAccess type. Some devices are direct access (it is possible to read/write anywhere) while others are sequential. QIODevice provides the access functions isDirectAccess(), isSequentialAccess() and isCombinedAccess() to tell users what a given I/O device supports..TPBuffering. Some devices are accessed in raw mode while others are buffered. Buffering usually provides greater efficiency, particularly for small read/write operations. isBuffered() tells the user whether a given device is buffered. (This can often be set by the application in the call to open().).TPSynchronicity. Synchronous devices work there and then, for example files. When you read from a file, the file delivers its data right away. Others, such as a socket connected to a HTTP server, may not deliver the data until seconds after you ask to read it. isSynchronous() and isAsynchronous() tells the user how this device operates..TPCR/LF translation. For simplicity, applications often like to see just a single CR/LF style, and QIODevice subclasses can provide that. isTranslated() returns TRUE if this object translates CR/LF to just LF. (This can often be set by the application in the call to open().).TPAccessibility. Some files cannot be written, for example. isReadable(), isWritable and isReadWrite() tells the application whether it can read from and write to a given device. (This can often be set by the application in the call to open().).TPFinally, isOpen() returns TRUE if the device is open. This can quite obviously be set using open() :).IP.PPQIODevice provides numerous pure virtual functions you need to implement when subclassing it. Here is a skeleton subclass with all the members you are certain to need, and some it's likely that you will need:.PP.nf.br    class YourDevice : public QIODevice.br    {.br    public:.br        YourDevice();.br       ~YourDevice();.br.br        bool open( int mode );.br        void close();.br        void flush();.br.br        uint size() const;.br        int  at() const;        // not a pure virtual function.br        bool at( int );         // not a pure virtual function.br        bool atEnd() const;     // not a pure virtual function.br.br        int readBlock( char *data, uint maxlen );.br        int writeBlock( const char *data, uint len );.br        int readLine( char *data, uint maxlen );.br.br        int getch();.br        int putch( int );.br        int ungetch( int );.br    };.fi.PPThe three non-pure virtual functions can be ignored if your device is sequential (e.g. an RS-232 port)..PPSee also QDataStream and QTextStream..SH MEMBER FUNCTION DOCUMENTATION.SH "QIODevice::QIODevice ()"Constructs an I/O device..SH "QIODevice::~QIODevice () \fC[virtual]\fR"Destructs the I/O device..SH "bool QIODevice::at ( int pos ) \fC[virtual]\fR"Virtual function that sets the I/O device index to \fIpos.\fR.PPSee also size()..PP

⌨️ 快捷键说明

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