QFileSystemWatcher empty QStringList file()
Hi everyone. I'm new here and I hope that someone can help me. I don't know what I'm doing wrong. My problem is that I am referring to a directory with 10 files but the function files() of QFileSystemWatcher class give me back a empty list. That's my code:
UploadDeleteFile.hpp
Code:
#ifndef UPLOADDELETEFILE_HPP_
#define UPLOADDELETEFILE_HPP_
#include "TestScheduler.hpp"
#include "accountInfoSettings.hpp"
#include <QFileSystemWatcher>
#include <QObject>
#include <QStringList>
class UploadDeleteFile
: public QObject{
Q_OBJECT
public:
UploadDeleteFile
(QObject *parent, TestScheduler
*myTestScheduler, accountInfoSettings
*myAccountInfoSettings
);
virtual ~UploadDeleteFile();
Q_INVOKABLE void setFileNameList();
accountInfoSettings *accountInfo;
TestScheduler *testScheduler;
int index;
};
#endif /* UPLOADDELETEFILE_HPP_ */
UploadDeleteFile.cpp
Code:
#include "FileUploader.hpp"
#include "MessageComposer.hpp"
#include "UploadDeleteFile.hpp"
#include <bb/system/SystemToast>
#include <stdio.h>
using namespace bb::cascades;
using namespace bb::pim::account;
using namespace bb::system;
UploadDeleteFile
::UploadDeleteFile(QObject *parent, TestScheduler
*myTestScheduler, accountInfoSettings
*myAccountInfoSettings
): QObject(parent
) { // TODO Auto-generated constructor stub
testScheduler = myTestScheduler;
accountInfo = myAccountInfoSettings;
index = -1;
filename = "";
}
UploadDeleteFile::~UploadDeleteFile() {
// TODO Auto-generated destructor stub
}
void UploadDeleteFile
::setFileName(QString name
){ filename = name;
}
void UploadDeleteFile::setFileNameList(){
fileSystem.addPath("data/Tests/");
filelist = fileSystem.files();
}
return filelist;
}
Any help is welcome. Thanks Carmen
Re: QFileSystemWatcher empty QStringList file()
You are not watching any files, only the directory "data/Tests/".
Cheers,
_
Re: QFileSystemWatcher empty QStringList file()
Could you give me more info? My files are in "data/Tests/" directory. I only need to read their names.
Thanks to replay me :)
Re: QFileSystemWatcher empty QStringList file()
Quote:
Originally Posted by
Carmengg
Could you give me more info?
The file system watcher can be told to watch files and directories. You are only watching a directory, thus files() returns an empty list.
Quote:
Originally Posted by
Carmengg
My files are in "data/Tests/" directory. I only need to read their names.
Maybe you are looking for QDir::entryList)()?
Cheers,
_
Re: QFileSystemWatcher empty QStringList file()
Thank you soooo much. That works :)