1 #include "mainwindow.h" 2 #include "ui_mainwindow.h" 3 #include 4 #include 5 #include 6 #include 7 8 MainWindow::MainWindow(QWidget *parent) : 9 QMainWindow(parent),10 ui(new Ui::MainWindow)11 {12 ui->setupUi(this);13 14 //获取指定目录15 QStringList args = qApp->arguments();16 QString path;17 if(args.count()>1)18 {19 path=args[1];20 }21 else22 {23 path = QDir::currentPath();24 }25 26 label = new QLabel(this);27 label->setText("spypath"+path);28 QVBoxLayout *layout = new QVBoxLayout(this);29 layout->addWidget(label);30 qDebug() << path;31 fsspy.addPath(path);32 connect(&fsspy,SIGNAL(directoryChanged(QString)),this,SLOT(directoryChanged(QString)));33 }34 35 MainWindow::~MainWindow()36 {37 delete ui;38 }39 40 //触发监视41 void MainWindow::directoryChanged(QString path)42 {43 QMessageBox::information(NULL,"changes",path);44 }