Hi all,

I am using a QFileSystemWatcher to keep an eye on a Picture on RAM disk.
When the picture is replace by another, which mean it is "modified".
and i would like to emit a signal and get the image to display on a QLabel.

It works when i use QTimer to replace the QFileSystemWatcher.

It seems QFileSystemWatcher is not emitting any signal.

my code ask following:

Qt Code:
  1. Dialog::Dialog(QWidget *parent) :
  2. QDialog(parent),
  3. ui(new Ui::Dialog)
  4. {
  5. ui->setupUi(this);
  6. /* timer = new QTimer(this);
  7.   timer->start(100);*/
  8.  
  9. watcher.addPath("/mnt/rd/frame.jpg");
  10. hsvSaveConnect();
  11. checkBox();
  12. connect(ui->save,SIGNAL(clicked()),this,SLOT(saveValueToSD()));
  13. connect(ui->load,SIGNAL(clicked()),this,SLOT(loadInitValue()));
  14. connect(&watcher,SIGNAL(fileChanged(const QString &)),this,SLOT(loadImage()));
  15. connect(&watcher,SIGNAL(directoryChanged(const QString &)),this,SLOT(loadImage()));
  16. qDebug() << watcher.files() << watcher.directories();
  17. }
  18.  
  19.  
  20. void Dialog::loadImage()
  21.  
  22.  
  23. {
  24.  
  25. qDebug() << "img loaded";
  26.  
  27.  
  28. QPixmap original("/mnt/rd/frame.jpg");
  29.  
  30.  
  31. if(original.isNull())
  32.  
  33.  
  34. {
  35.  
  36. qDebug()<<"Failed to load image.";
  37.  
  38.  
  39. }
  40.  
  41. ui->original->setPixmap(original);
  42.  
  43.  
  44. }
To copy to clipboard, switch view to plain text mode