Im working with threads. In the following code, i read datas from txt and run it on my thread. I want to use another thread for writing the datas another txt file. How can i do it?

mythread.cpp


Qt Code:
  1. #include "mythread.h"
  2. #include <QtCore>
  3. #include <QDebug>
  4. #include <QFile>
  5. MyThread::MyThread()
  6. {
  7.  
  8. }
  9.  
  10. void MyThread::run() //Reading file from txt with thread1
  11. {
  12. QFile file("C:/Users/ilknu/Documents/untitled1/deneme.txt");
  13.  
  14. if (file.open(QIODevice::ReadOnly))
  15. {
  16. QTextStream in (&file);
  17. while (!in.atEnd())
  18. {
  19.  
  20. QString line = in.readLine();
  21. QStringList list = line.split(QLatin1Char(' '), Qt::SkipEmptyParts);
  22. for(const QString &entry : list)
  23. {
  24. double num = entry.toDouble();
  25. qDebug()<<num;
  26. queue.enqueue(num);
  27.  
  28. } // for
  29. } // while
  30. } // if
  31.  
  32. file.close();
  33. }
To copy to clipboard, switch view to plain text mode