Results 1 to 5 of 5

Thread: QFileSystemWatcher empty QStringList file()

  1. #1
    Join Date
    Jan 2014
    Posts
    7
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default 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

    Qt Code:
    1. #ifndef UPLOADDELETEFILE_HPP_
    2. #define UPLOADDELETEFILE_HPP_
    3.  
    4. #include "TestScheduler.hpp"
    5. #include "accountInfoSettings.hpp"
    6. #include <QFileSystemWatcher>
    7. #include <QObject>
    8. #include <QStringList>
    9.  
    10. class UploadDeleteFile : public QObject{
    11.  
    12. Q_OBJECT
    13.  
    14. public:
    15. UploadDeleteFile(QObject *parent, TestScheduler *myTestScheduler, accountInfoSettings *myAccountInfoSettings);
    16. virtual ~UploadDeleteFile();
    17.  
    18. QStringList getFileNameList();
    19. Q_INVOKABLE void setFileNameList();
    20.  
    21. accountInfoSettings *accountInfo;
    22. QFileSystemWatcher fileSystem;
    23. TestScheduler *testScheduler;
    24. QStringList filelist;
    25. QString filename;
    26. int index;
    27. };
    28.  
    29. #endif /* UPLOADDELETEFILE_HPP_ */
    To copy to clipboard, switch view to plain text mode 


    UploadDeleteFile.cpp

    Qt Code:
    1. #include "FileUploader.hpp"
    2. #include "MessageComposer.hpp"
    3. #include "UploadDeleteFile.hpp"
    4.  
    5. #include <bb/system/SystemToast>
    6. #include <stdio.h>
    7.  
    8. using namespace bb::cascades;
    9. using namespace bb::pim::account;
    10. using namespace bb::system;
    11.  
    12. UploadDeleteFile::UploadDeleteFile(QObject *parent, TestScheduler *myTestScheduler, accountInfoSettings *myAccountInfoSettings): QObject(parent) {
    13. // TODO Auto-generated constructor stub
    14. testScheduler = myTestScheduler;
    15. accountInfo = myAccountInfoSettings;
    16. index = -1;
    17. filename = "";
    18. filelist = QStringList();
    19. }
    20.  
    21. UploadDeleteFile::~UploadDeleteFile() {
    22. // TODO Auto-generated destructor stub
    23. }
    24.  
    25. void UploadDeleteFile::setFileName(QString name){
    26. filename = name;
    27. }
    28.  
    29. void UploadDeleteFile::setFileNameList(){
    30. fileSystem.addPath("data/Tests/");
    31. QStringList directories = fileSystem.directories();
    32. filelist = fileSystem.files();
    33. }
    34.  
    35. QStringList UploadDeleteFile::getFileNameList(){
    36. return filelist;
    37. }
    To copy to clipboard, switch view to plain text mode 

    Any help is welcome. Thanks Carmen

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QFileSystemWatcher empty QStringList file()

    You are not watching any files, only the directory "data/Tests/".

    Cheers,
    _

  3. #3
    Join Date
    Jan 2014
    Posts
    7
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default 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

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QFileSystemWatcher empty QStringList file()

    Quote Originally Posted by Carmengg View Post
    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 View Post
    My files are in "data/Tests/" directory. I only need to read their names.
    Maybe you are looking for QDir::entryList)()?

    Cheers,
    _

  5. #5
    Join Date
    Jan 2014
    Posts
    7
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: QFileSystemWatcher empty QStringList file()

    Thank you soooo much. That works

Similar Threads

  1. Replies: 0
    Last Post: 23rd December 2013, 12:31
  2. qstringlist output to file
    By martial_arts_drummer in forum Qt Programming
    Replies: 9
    Last Post: 27th February 2011, 21:05
  3. Replies: 4
    Last Post: 3rd August 2010, 07:17
  4. Replies: 3
    Last Post: 21st August 2009, 11:39
  5. Qhttp get in qt3 to file? file is empty until app is close?
    By triperzonak in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2008, 15:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.