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
#include "mythread.h"
#include <QtCore>
#include <QDebug>
#include <QFile>
MyThread::MyThread()
{
}
void MyThread::run() //Reading file from txt with thread1
{
QFile file("C:/Users/ilknu/Documents/untitled1/deneme.txt");
{
while (!in.atEnd())
{
{
double num = entry.toDouble();
qDebug()<<num;
queue.enqueue(num);
} // for
} // while
} // if
file.close();
}
#include "mythread.h"
#include <QtCore>
#include <QDebug>
#include <QFile>
MyThread::MyThread()
{
}
void MyThread::run() //Reading file from txt with thread1
{
QFile file("C:/Users/ilknu/Documents/untitled1/deneme.txt");
if (file.open(QIODevice::ReadOnly))
{
QTextStream in (&file);
while (!in.atEnd())
{
QString line = in.readLine();
QStringList list = line.split(QLatin1Char(' '), Qt::SkipEmptyParts);
for(const QString &entry : list)
{
double num = entry.toDouble();
qDebug()<<num;
queue.enqueue(num);
} // for
} // while
} // if
file.close();
}
To copy to clipboard, switch view to plain text mode
Bookmarks