资源简介
一个很好用的跨平台的USB设备(比如USB鼠标、U盘等)热插拔 QT库。兼容LINUX(Ubuntu),WINDOWS,WINCE,MAC OS。带有终端以及GUI例子,方便运行测试。

代码片段和文件信息
/******************************************************************************
QDeviceWatcher: Device watcher class
Copyright (C) 2011-2015 Wang Bin
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License or (at your option) any later version.
This library is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not write to the Free Software
Foundation Inc. 51 Franklin Street Fifth Floor Boston MA 02110-1301 USA
******************************************************************************/
#include “qdevicewatcher.h“
#include “qdevicewatcher_p.h“
QDeviceWatcher::QDeviceWatcher(Qobject* parent)
:Qobject(parent)running(false)d_ptr(new QDeviceWatcherPrivate)
{
Q_D(QDeviceWatcher);
d->setWatcher(this);
}
QDeviceWatcher::~QDeviceWatcher()
{
if (d_ptr) {
delete d_ptr;
d_ptr = NULL;
}
}
bool QDeviceWatcher::start()
{
Q_D(QDeviceWatcher);
if (!d->start()) {
stop();
running = false;
}
running = true;
return running;
}
bool QDeviceWatcher::stop()
{
Q_D(QDeviceWatcher);
running = !d->stop();
return !running;
}
bool QDeviceWatcher::isRunning() const
{
return running;
}
void QDeviceWatcher::appendEventReceiver(Qobject *receiver)
{
Q_D(QDeviceWatcher);
d->event_receivers.append(receiver);
}
void QDeviceWatcherPrivate::emitDeviceAdded(const QString &dev)
{
if (!Qmetaobject::invokeMethod(watcher “deviceAdded“ Q_ARG(QString dev)))
qWarning(“invoke deviceAdded failed“);
}
void QDeviceWatcherPrivate::emitDeviceChanged(const QString &dev)
{
if (!Qmetaobject::invokeMethod(watcher “deviceChanged“ Q_ARG(QString dev)))
qWarning(“invoke deviceChanged failed“);
}
void QDeviceWatcherPrivate::emitDeviceRemoved(const QString &dev)
{
if (!Qmetaobject::invokeMethod(watcher “deviceRemoved“ Q_ARG(QString dev)))
qWarning(“invoke deviceRemoved failed“);
}
void QDeviceWatcherPrivate::emitDeviceAction(const QString &dev const QString &action)
{
QString a(action.toLower());
if (a == QLatin1String(“add“))
emitDeviceAdded(dev);
else if (a == QLatin1String(“remove“))
emitDeviceRemoved(dev);
else if (a == QLatin1String(“change“))
emitDeviceChanged(dev);
}
//const QEvent::Type QDeviceChangeEvent::EventType = static_cast(QEvent::registerEventType());
QDeviceChangeEvent::QDeviceChangeEvent(Action action const QString &device) :
QEvent(registeredType())
{
m_action = action;
m_device = device;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 326 2018-03-29 09:55 QDeviceWatcher.pro
文件 16473 2018-03-29 09:55 common.pri
目录 0 2018-08-24 09:21 screenshot\
文件 151898 2018-03-29 09:55 screenshot\ubuntu-gui-debug.png
文件 56479 2018-03-29 09:55 screenshot\ubuntu.png
文件 19680 2018-03-29 09:55 screenshot\win7-gui-debug.png
文件 36428 2018-03-29 09:55 screenshot\win7.png
文件 48029 2018-03-29 09:55 screenshot\wince-emu-gui.PNG
目录 0 2018-08-24 09:21 src\
文件 4351 2018-03-29 09:55 src\libQDeviceWatcher.pri
文件 589 2018-03-29 09:55 src\libQDeviceWatcher.pro
文件 2895 2018-03-29 09:55 src\qdevicewatcher.cpp
文件 2461 2018-03-29 09:55 src\qdevicewatcher.h
文件 7912 2018-03-29 09:55 src\qdevicewatcher_linux.cpp
文件 2921 2018-03-29 09:55 src\qdevicewatcher_mac.cpp
文件 3333 2018-03-29 09:55 src\qdevicewatcher_p.h
文件 12881 2018-03-29 09:55 src\qdevicewatcher_win32.cpp
文件 3924 2018-03-29 09:55 src\qdevicewatcher_wince.cpp
目录 0 2018-08-24 09:21 test\
文件 3067 2018-03-29 09:55 test\hotplugwatcher.h
文件 396 2018-03-29 09:55 test\hotplugwatcher.pro
文件 3911 2018-03-29 09:55 test\hotplugwatcher_gui.cpp
文件 1793 2018-03-29 09:55 test\hotplugwatcher_gui.h
文件 455 2018-03-29 09:55 test\hotplugwatcher_gui.pro
文件 1246 2018-03-29 09:55 test\main.cpp
文件 1669 2018-03-29 09:55 test\main_gui.cpp
- 上一篇:自编labview小程序
- 下一篇:Labview 2015注册机
相关资源
- usb hid调试工具
- HID调试助手
- USB.Over.Network.Server 注册机
- WPF USB 网络 串口 通信软件
- USB转串口驱动,FT232R驱动程序,最新
- WinCE下CP210x的驱动程序
- hidusage.h hidpi.h 等USB开发用头文件
- 基于JM20329的SATA转USB 1394
- 430系列单片机USBFET下载驱动
- CY7C68013A固件程序(用于摄像机采集)
- usb调试程序 对USB设备进行数据的读写
- USB 驱动 让电脑与arm进行通信
- USB助手(调试USB通信协议的工具) 源
- 基于FPGA的USB接口设计
- 枚举USB设备接口(C 源代码)
- 多普达USB Modem驱动(适用于818、828、
- SN9C291B datasheet
- 希捷公布USB外部硬盘解决方案
- USB调试模式一键设置
- USB网卡驱动 USB2.0 TO Fast Ethernet Adapte
- USB转串口(RS232/RS485/RS422)驱动程序文
- USB Type-C SPEC
- H310.B360.H370.Z390.USB WIN7 64位第三方驱动
- 300系列WIN7 USB驱动.7z
- 华硕P8H61/USB3 R2.0主板BIOS驱动 免费版
- RTL8188EVT USB WIFI无线网卡驱动 免费版
- RTL8188 USB无线网卡模块完整方案
- USB PCB布局布线要点及注意事项
- USB驱动 INF中的服务安装段落无效的原
- MTP USB驱动win7 32+64位可用版
评论
共有 条评论