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
#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_ */
#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();
QStringList getFileNameList();
Q_INVOKABLE void setFileNameList();
accountInfoSettings *accountInfo;
QFileSystemWatcher fileSystem;
TestScheduler *testScheduler;
QStringList filelist;
QString filename;
int index;
};
#endif /* UPLOADDELETEFILE_HPP_ */
To copy to clipboard, switch view to plain text mode
UploadDeleteFile.cpp
#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;
}
#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 = "";
filelist = QStringList();
}
UploadDeleteFile::~UploadDeleteFile() {
// TODO Auto-generated destructor stub
}
void UploadDeleteFile::setFileName(QString name){
filename = name;
}
void UploadDeleteFile::setFileNameList(){
fileSystem.addPath("data/Tests/");
QStringList directories = fileSystem.directories();
filelist = fileSystem.files();
}
QStringList UploadDeleteFile::getFileNameList(){
return filelist;
}
To copy to clipboard, switch view to plain text mode
Any help is welcome. Thanks Carmen
Bookmarks