Qt-输入/输出设备(API & source code 简要分析,一小部分)

来源:互联网 发布:windows repair汉化版 编辑:程序博客网 时间:2024/06/12 01:01

引入:

通过《Qt Creator快速入门 - 第二版》(霍亚飞)学习Qt Gui编程时,在第15.1.1节开始处介绍了QIODevice类,Qt  5.7.0 Reference Documentation - Classes中对QIODevice类的介绍如下(节选)

Detailed Description

The QIODevice class is the base interface class of all I/O devices in Qt.

QIODevice provides both a common implementation and an abstract interface for devices that support reading and writing of blocks of data, such as QFile,QBuffer andQTcpSocket.QIODevice is abstract and can not be instantiated, but it is common to use the interface it defines to provide device-independent I/O features. For example, Qt's XML classes operate on a QIODevice pointer, allowing them to be used with various devices (such as files and buffers).

Before accessing the device, open() must be called to set the correct OpenMode (such as ReadOnly or ReadWrite). You can then write to the device withwrite() orputChar(), and read by calling eitherread(),readLine(), orreadAll(). Callclose() when you are done with the device.

0 0
原创粉丝点击