QUsbDevice Class

This class handles opening and configuring the device. More...

Header: #include <QUsbDevice>
qmake: QT += usb
Inherits: QObject

Note: All functions in this class are reentrant.

Public Types

class Config
class Id
typedef ConfigList
enum DeviceSpeed { unknownSpeed, lowSpeed, fullSpeed, highSpeed, superSpeed, superSpeedPlus }
enum DeviceStatus { statusOK, statusIoError, statusInvalidParam, statusAccessDenied, ..., StatusUnknownError }
typedef Endpoint
typedef IdList
enum LogLevel { logNone, logError, logWarning, logInfo, logDebug, logDebugAll }

Properties

  • 1 property inherited from QObject

Public Functions

QUsbDevice(QObject *parent = Q_NULLPTR)
~QUsbDevice()
Config config() const
Id id() const
bool isConnected() const
LogLevel logLevel() const
quint16 pid() const
void setConfig(const Config &config)
void setId(const Id &id)
void setLogLevel(LogLevel level)
void setTimeout(quint16 timeout)
DeviceSpeed speed() const
QByteArray speedString() const
quint16 timeout() const
quint16 vid() const
  • 32 public functions inherited from QObject

Public Slots

void close()
qint32 open()
  • 1 public slot inherited from QObject

Static Public Members

IdList devices()
  • 10 static public members inherited from QObject

Additional Inherited Members

  • 2 signals inherited from QObject
  • 1 public variable inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

This class handles opening and configuring the device.

Member Type Documentation

typedef QUsbDevice::ConfigList

List of Config structs.

enum QUsbDevice::DeviceSpeed

ConstantValueDescription
QUsbDevice::unknownSpeed-1Speed is unkown
QUsbDevice::lowSpeed0USB 1.0
QUsbDevice::fullSpeed1USB 1.1/2.0
QUsbDevice::highSpeed2USB 2.0
QUsbDevice::superSpeed3USB 3.0/3.1 G1
QUsbDevice::superSpeedPlus4USB 3.1 G2

enum QUsbDevice::DeviceStatus

ConstantValueDescription
QUsbDevice::statusOK0Success (no error)
QUsbDevice::statusIoError-1Input/output error
QUsbDevice::statusInvalidParam-2Invalid parameter
QUsbDevice::statusAccessDenied-3Access denied (insufficient permissions)
QUsbDevice::statusNoSuchDevice-4No such device (it may have been disconnected)
QUsbDevice::statusNotFound-5Entity not found
QUsbDevice::statusBusy-6Resource busy
QUsbDevice::statusTimeout-7Operation timed out
QUsbDevice::statusOverflow-8Overflow
QUsbDevice::statusPipeError-9Pipe error
QUsbDevice::statusInterrupted-10System call interrupted (perhaps due to signal)
QUsbDevice::statusNoMemory-11Insufficient memory
QUsbDevice::statusNotSupported-12Operation not supported or unimplemented on this platform
QUsbDevice::StatusUnknownError-99Other error

typedef QUsbDevice::Endpoint

An endpoint ID.

typedef QUsbDevice::IdList

List of Id structs.

enum QUsbDevice::LogLevel

ConstantValueDescription
QUsbDevice::logNone0No debug output
QUsbDevice::logError1Errors only
QUsbDevice::logWarning2Warning and abose
QUsbDevice::logInfo3Info and above
QUsbDevice::logDebug4Everything
QUsbDevice::logDebugAll5Everything + libusb debug output

Property Documentation

config : Config

Various properties.

Access functions:

Config config() const
void setConfig(const Config &config)

id : Id

Various properties.

Access functions:

Id id() const
void setId(const Id &id)

logLevel : LogLevel

Various properties.

Access functions:

LogLevel logLevel() const
void setLogLevel(LogLevel level)

pid : const quint16

Various properties.

Access functions:

quint16 pid() const

speed : const DeviceSpeed

Various properties.

Access functions:

DeviceSpeed speed() const

timeout : quint16

Various properties.

Access functions:

quint16 timeout() const
void setTimeout(quint16 timeout)

vid : const quint16

Various properties.

Access functions:

quint16 vid() const

Member Function Documentation

QUsbDevice::QUsbDevice(QObject *parent = Q_NULLPTR)

Default constructs an instance of QUsbDevice.

QUsbDevice::~QUsbDevice()

Destructor.

[slot] void QUsbDevice::close()

Close the device.

Config QUsbDevice::config() const

Returns the current config.

Note: Getter function for property config.

See also setConfig().

[static] IdList QUsbDevice::devices()

Returns all present devices.

Id QUsbDevice::id() const

Returns the device id.

Note: Getter function for property id.

See also setId().

bool QUsbDevice::isConnected() const

Returns true if connected.

LogLevel QUsbDevice::logLevel() const

Returns the log level.

Note: Getter function for property logLevel.

See also setLogLevel().

[slot] qint32 QUsbDevice::open()

Open the device. Returns 0 on success

quint16 QUsbDevice::pid() const

Return the device pid. (Product id)

Note: Getter function for property pid.

void QUsbDevice::setLogLevel(LogLevel level)

Set the log level.

Note: Setter function for property logLevel.

See also logLevel().

void QUsbDevice::setTimeout(quint16 timeout)

Set the device timeout.

Note: Setter function for property timeout.

See also timeout().

DeviceSpeed QUsbDevice::speed() const

Returns the device speed.

Note: Getter function for property speed.

QByteArray QUsbDevice::speedString() const

Returns the current speed as a human readable string.

quint16 QUsbDevice::timeout() const

Return the timeout.

Note: Getter function for property timeout.

See also setTimeout().

quint16 QUsbDevice::vid() const

Return the device vid. (Vendor id)

Note: Getter function for property vid.