QFileSystemWatcher使用整理
来源:互联网 发布:上海巨人网络校园招聘 编辑:程序博客网 时间:2024/05/22 05:08
1.效果图
2.源代码
watch.h
#ifndef WATCHER_H#define WATCHER_H#include <QWidget>#include <QLabel>#include <QFileSystemWatcher>class Watcher : public QWidget{ Q_OBJECTpublic: Watcher(QWidget *parent = 0); ~Watcher();public slots: void directoryChanged(QString path);//目录发生变化时响应private: QLabel *pathLabel; QFileSystemWatcher fsWatcher;};#endif // WATCHER_H
watch.cpp
#include "watcher.h"#include <QVBoxLayout>#include <QDir>#include <QMessageBox>#include <QApplication>Watcher::Watcher(QWidget *parent) : QWidget(parent){ QStringList args=qApp->arguments(); QString path = "D:/document";// if(args.count()>1)// {// path=args[1];// }// else// {// path=QDir::currentPath();// } pathLabel = new QLabel; pathLabel->setText(tr("监视的目录:")+path); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(pathLabel); fsWatcher.addPath(path); connect(&fsWatcher,SIGNAL(directoryChanged(QString)),this,SLOT(directoryChanged(QString)));}Watcher::~Watcher(){}void Watcher::directoryChanged(QString path){ QMessageBox::information(NULL,tr("目录发生变化"),path);}
阅读全文
0 0
- QFileSystemWatcher使用整理
- QFileSystemWatcher 使用
- QT之QFileSystemWatcher使用
- QFileSystemWatcher
- 使用QFileSystemWatcher监控磁盘文件状态变化
- QFileSystemWatcher缺少main.cpp
- Qt之QFileSystemWatcher
- QFileSystemWatcher Qt 实现文件监测
- Qt监测系统文件变化QFileSystemWatcher
- EXISTS的使用(整理)
- mysql使用心得整理
- solr使用整理
- ant使用整理
- sh脚本使用整理
- Dozer使用 整理
- Dozer使用 整理2
- FCKEditor 使用整理
- Wix使用整理(一)
- 【微信小程序】支付过程详解
- js正则表达式中test,exec,match方法的区别说明
- 如何备份SolidWorks网络版服务器
- codeforces 682C Alyona and the Tree
- equals重写
- QFileSystemWatcher使用整理
- nginx报错:nginx.service failed to run 'start-pre' task: No space left on device
- 栈-leetcode 496. Next Greater Element I
- (python)百练1000: A+B Problem
- SSM框架中,mybits.xml配置,映射器的注意点
- 【前端】Handlebars,requirejs使用入门
- 历史图纸导入PDM方案
- Maven整合SSM三大框架
- 简单的春鞋!