QCanBusDeviceInfo Class
QCanBusDeviceInfo 提供了有关 CAN 总线接口的信息。更多内容...
| 头文件: | #include <QCanBusDeviceInfo> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS SerialBus) target_link_libraries(mytarget PRIVATE Qt6::SerialBus) |
| qmake: | QT += serialbus |
公共函数
| QCanBusDeviceInfo() | |
| QCanBusDeviceInfo(const QCanBusDeviceInfo &other) | |
(since 6.10) | QCanBusDeviceInfo(QCanBusDeviceInfo &&other) |
| ~QCanBusDeviceInfo() | |
(since 6.0) QString | alias() const |
| int | channel() const |
| QString | description() const |
| bool | hasFlexibleDataRate() const |
| bool | isVirtual() const |
| QString | name() const |
(since 6.2) QString | plugin() const |
| QString | serialNumber() const |
| void | swap(QCanBusDeviceInfo &other) |
| QCanBusDeviceInfo & | operator=(QCanBusDeviceInfo &&other) |
| QCanBusDeviceInfo & | operator=(const QCanBusDeviceInfo &other) |
成员函数文档
[delete] QCanBusDeviceInfo::QCanBusDeviceInfo()
默认构造一个QCanBusDeviceInfo 实例。此函数已被删除。
QCanBusDeviceInfo::QCanBusDeviceInfo(const QCanBusDeviceInfo &other)
创建other 的副本。
[constexpr noexcept default, since 6.10] QCanBusDeviceInfo::QCanBusDeviceInfo(QCanBusDeviceInfo &&other)
从other 构建 CAN 总线设备信息。
该函数于 Qt 6.10 中引入。
[noexcept] QCanBusDeviceInfo::~QCanBusDeviceInfo()
清除 CAN 总线设备信息。
[since 6.0] QString QCanBusDeviceInfo::alias() const
返回与该 CAN 总线接口关联的用户可定义别名。
某些 CAN 总线接口可以关联一个用户定义的别名。这通常通过 CAN 硬件供应商提供的工具来实现。该别名便于日后识别该硬件,特别是在连接了多个接口的情况下。
注意: 与serialNumber()不同 ,无法保证别名具有唯一性。
如果 CAN 插件不支持此函数,则返回空字符串。
该函数在 Qt 6.0 中引入。
另请参阅 serialNumber()。
int QCanBusDeviceInfo::channel() const
返回 CAN 总线接口的顺序通道编号,从零开始计数。例如,一个双通道 CAN 接口可能包含通道 0 和 1。如果接口只有一个通道,或者没有关于该通道的信息,则返回零。
QString QCanBusDeviceInfo::description() const
返回 CAN 总线接口的文本描述(如有)。输出示例:“PCAN USB Pro FD”。如果没有描述,则返回空字符串。
bool QCanBusDeviceInfo::hasFlexibleDataRate() const
如果 CAN 总线接口支持 CAN FD(灵活数据速率),则返回 true。
如果无法获取此信息,则返回 false。
bool QCanBusDeviceInfo::isVirtual() const
如果 CAN 总线接口为虚拟接口(即未连接到真实的 CAN 硬件),则返回 true。
如果无法获取此信息,则返回 false。
QString QCanBusDeviceInfo::name() const
返回此 CAN 总线接口的接口名称,例如“can0”。
这对应于QCanBus::createDevice()中的interfaceName 参数。
[since 6.2] QString QCanBusDeviceInfo::plugin() const
返回此 CAN 总线接口的插件名称,例如“peakcan”。
这对应于QCanBus::createDevice() 函数中的plugin 参数。
该函数在 Qt 6.2 中引入。
QString QCanBusDeviceInfo::serialNumber() const
如果可用,则返回 CAN 总线接口的序列号(字符串形式);否则,返回空字符串。
另请参阅 alias()。
[noexcept] void QCanBusDeviceInfo::swap(QCanBusDeviceInfo &other)
将此CAN总线设备的信息与other 互换。此操作速度极快,且从不会失败。
[noexcept] QCanBusDeviceInfo &QCanBusDeviceInfo::operator=(QCanBusDeviceInfo &&other)
将other 通过move-assign操作赋值给该QCanBusDeviceInfo 实例。
QCanBusDeviceInfo &QCanBusDeviceInfo::operator=(const QCanBusDeviceInfo &other)
将other 分配给该CAN总线设备信息,并返回对此CAN总线设备信息的引用。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.