本页内容

QCanBusFactory Class

QCanBusFactory 类是一个工厂类,用作 CAN 总线插件的插件接口。更多内容...

头文件: #include <QCanBusFactory>
CMake: find_package(Qt6 REQUIRED COMPONENTS SerialBus)
target_link_libraries(mytarget PRIVATE Qt6::SerialBus)
qmake: QT += serialbus

公共函数

virtual QList<QCanBusDeviceInfo> availableDevices(QString *errorMessage) const = 0
virtual QCanBusDevice *createDevice(const QString &interfaceName, QString *errorMessage) const = 0

详细说明

所有插件都必须实现此工厂类提供的函数。

成员函数文档

[pure virtual] QList<QCanBusDeviceInfo> QCanBusFactory::availableDevices(QString *errorMessage) const

返回QCanBusDevice 中可用设备的列表及其功能。

errorMessage 若操作失败,则包含错误描述。

[pure virtual] QCanBusDevice *QCanBusFactory::createDevice(const QString &interfaceName, QString *errorMessage) const

创建一个新的QCanBusDevice 。调用方必须获得返回指针的所有权。

interfaceName 是 CAN 接口名称,errorMessage 在操作失败时包含错误描述。

如果工厂无法创建插件,则返回 `nullptr`。

© 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.