资源简介
一个很好用的跨平台的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注册机
相关资源
- 基于UPD720114的USB HUB电路设计
- usb转串口线驱动max232
- 易语言USB操作模块
- CYUSB3014中文数据手册
- linux PL2303 usb转串口驱动源码
- 利用 EZ-USB® FX3 从器件 FIFO 接口进行设
- usb3.0官方开发板cyusb3014原理图
- 自行实现的Linux内核USB鼠标驱动
- USB Dongle驱动
- 真正RTL8812AU的Datasheet,USB3.0,802.11a
- PSP USB驱动 Type B
- imx6q直接从USB OTG运行uboot方法
- ArduinoUSBKeyboard库文件
- opencv读取usb摄像头和播放视频
- 基于labview的USB摄像头运动目标捕捉系
- lcx修改版端口转发工具,内网端口转
- STM32F407 USB虚拟串口
- 基于mini2440的USB视频采集
- hotplug 热插拔 测试程序
- zedboard的usb视频显示
- Cy7C68013A电路原理图,USB2.0
- WindowsXP环境下USB设备驱动程序的开发
- labview USB 控制传输 调试助手
- Mini USB和Micro USB的PCB封装
- USB2.0_A型、B型、Mini和Micro接口定义及
- CNC USB Controllers keygen
- LabVIEW与USB串口通信源代码
- FT245 usb fifo control
- usb3nvme.txt
- 银灿IS917U盘PCB电路原理图+PCB图-其它其
评论
共有 条评论