QSerialPortInfo Class

QSerialPortInfo 提供了系统中现有串口的相关信息. More...

头文件: #include <QSerialPortInfo>
qmake: QT += serialport
开始支持版本: Qt 5.1

公有函数

QSerialPortInfo(const QSerialPortInfo &other)
QSerialPortInfo(const QString &name)
QSerialPortInfo(const QSerialPort &port)
QSerialPortInfo()
QSerialPortInfo &operator=(const QSerialPortInfo &other)
~QSerialPortInfo()
QString description() const
bool hasProductIdentifier() const
bool hasVendorIdentifier() const
bool isNull() const
QString manufacturer() const
QString portName() const
quint16 productIdentifier() const
QString serialNumber() const
void swap(QSerialPortInfo &other)
QString systemLocation() const
quint16 vendorIdentifier() const

静态公有成员

QList<QSerialPortInfo> availablePorts()
QList<qint32> standardBaudRates()

详细描述

使用静态函数生成 QSerialPortInfo 类实例对象列表. 列表中的每一个 QSerialPortInfo 对象代表一个串口设备, 可以通过串口名, 系统地址, 设备描述以及制造商查询串口. QSerialPortInfo 类还可以用作 QSerialPort 类成员方法 setPort() 的输入参数.

另见 QSerialPort.

Member Function Documentation

QSerialPortInfo::QSerialPortInfo(const QSerialPortInfo &other)

Constructs a copy of other.

QSerialPortInfo::QSerialPortInfo(const QString &name)

Constructs a QSerialPortInfo object from serial port name.

This constructor finds the relevant serial port among the available ones according to the port name name, and constructs the serial port info instance for that port.

QSerialPortInfo::QSerialPortInfo(const QSerialPort &port)

Constructs a QSerialPortInfo object from serial port.

QSerialPortInfo::QSerialPortInfo()

Constructs an empty QSerialPortInfo object.

See also isNull().

QSerialPortInfo &QSerialPortInfo::operator=(const QSerialPortInfo &other)

Sets the QSerialPortInfo object to be equal to other.

QSerialPortInfo::~QSerialPortInfo()

Destroys the QSerialPortInfo object. References to the values in the object become invalid.

[static] QList<QSerialPortInfo> QSerialPortInfo::availablePorts()

Returns a list of available serial ports on the system.

QString QSerialPortInfo::description() const

Returns the description string of the serial port, if available; otherwise returns an empty string.

See also manufacturer() and serialNumber().

bool QSerialPortInfo::hasProductIdentifier() const

Returns true if there is a valid 16-bit product number present; otherwise returns false.

See also productIdentifier(), vendorIdentifier(), and hasVendorIdentifier().

bool QSerialPortInfo::hasVendorIdentifier() const

Returns true if there is a valid 16-bit vendor number present; otherwise returns false.

See also vendorIdentifier(), productIdentifier(), and hasProductIdentifier().

bool QSerialPortInfo::isNull() const

Returns whether this QSerialPortInfo object holds a serial port definition.

See also isBusy().

QString QSerialPortInfo::manufacturer() const

Returns the manufacturer string of the serial port, if available; otherwise returns an empty string.

See also description() and serialNumber().

QString QSerialPortInfo::portName() const

Returns the name of the serial port.

See also systemLocation().

quint16 QSerialPortInfo::productIdentifier() const

Returns the 16-bit product number for the serial port, if available; otherwise returns zero.

See also hasProductIdentifier(), vendorIdentifier(), and hasVendorIdentifier().

QString QSerialPortInfo::serialNumber() const

Returns the serial number string of the serial port, if available; otherwise returns an empty string.

Note: The serial number may include letters.

This function was introduced in Qt 5.3.

See also description() and manufacturer().

[static] QList<qint32> QSerialPortInfo::standardBaudRates()

Returns a list of available standard baud rates supported by the target platform.

void QSerialPortInfo::swap(QSerialPortInfo &other)

Swaps QSerialPortInfo other with this QSerialPortInfo. This operation is very fast and never fails.

QString QSerialPortInfo::systemLocation() const

Returns the system location of the serial port.

See also portName().

quint16 QSerialPortInfo::vendorIdentifier() const

Returns the 16-bit vendor number for the serial port, if available; otherwise returns zero.

See also hasVendorIdentifier(), productIdentifier(), and hasProductIdentifier().