Here is my project:

clean.h

Qt Code:
  1. #include <QtGui/QApplication>
  2. #include "qmlapplicationviewer.h"
  3. #include <QObject>
  4. #include <QApplication>
  5. #include <QDeclarativeView>
  6. #include <QDeclarativeContext>
  7.  
  8. #ifndef CLEAN_H
  9. #define CLEAN_H
  10.  
  11.  
  12. class Clean : public QObject {
  13. Q_OBJECT
  14. public:
  15. explicit Clean(QObject *parent = 0); ~Clean();
  16.  
  17. //void deleteDir();
  18. //void deleteFile();
  19.  
  20. Q_INVOKABLE void clean1();
  21. };
  22.  
  23. #endif // CLEAN_H
To copy to clipboard, switch view to plain text mode 

clean.cpp

Qt Code:
  1. #include <QtGui/QApplication>
  2. #include "qmlapplicationviewer.h"
  3. #include <QObject>
  4. #include <QApplication>
  5. #include <QDeclarativeView>
  6. #include <QDeclarativeContext>
  7. #include <QFile>
  8. #include <QDir>
  9. #include "clean.h"
  10.  
  11. void deleteDir(const std::string& foldername) {
  12. QDir dir;
  13. dir.remove(foldername.c_str());
  14. }
  15.  
  16. void deleteFile(const std::string& filename) {
  17. QFile file;
  18. file.remove(filename.c_str());
  19. }
  20.  
  21. Clean::Clean(QObject *parent) : QObject(parent) {
  22. }
  23.  
  24. Clean::~Clean() {
  25. }
  26.  
  27. void Clean::clean1() {
  28. deleteDir(e:/data);
  29. deleteFile(e:/qf)
  30. }
To copy to clipboard, switch view to plain text mode 


main.cpp

Qt Code:
  1. #include "clean.h"
  2.  
  3. int main(int argc, char *argv[])
  4. {
  5. QApplication app(argc, argv);
  6.  
  7. Clean clean;
  8.  
  9. QDeclarativeView view;
  10. view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
  11. view.rootContext()->setContextProperty("Clean", &clean);
  12. view.setSource(QUrl("qml/GCleaner/main.qml"));
  13.  
  14. return app.exec();
  15. }
To copy to clipboard, switch view to plain text mode 

main.qml

Qt Code:
  1. Button {
  2. id:button
  3. onClicked: Clean.clean1()
  4. }
To copy to clipboard, switch view to plain text mode 


It works very well on Qt Simulator, but not work on my mobile device. I also tried to add qdir.h and qfile.h but it exited with code -1073741819.

What should I do? Thank you so much for your help.