Open File in a class and have access to it in another class
Hi,
In my Dialogclass I open a file
Code:
ui->FileEdit->setText(filepath);
ui->UpdateProgressBar->setRange(0,(file.size()-firstlineArray.size()));
firstlineArray.chop(1);
devicetypeFromFile = firstlineArray.toInt();
enableUpdateButton(true);
}
Now I want to have access to this file in my WorkerThread Class, because I need to read some lines from this file (it's a file with many hex-lines). The Dialog starts with a click on a Button the WorkerThread.
What is the best way to get the file to my Worker Thread?
Re: Open File in a class and have access to it in another class
1) You create the file on the heap
2) You pass it to the thread's constructor and store it in a member of the thread
3) You all moveToThread on the file object
4) You use the file in the thread and let it delete it when you are done
Cheers,
_
Re: Open File in a class and have access to it in another class
Okay I created the file on the heap now.
I don't understand the next steps, can you give me an example please? :)
Re: Open File in a class and have access to it in another class
I assume you mean the moveToThread, everything else is basic C++ just like creating on the heap.
Code:
file->moveToThread(this);
Cheers,
_
Re: Open File in a class and have access to it in another class
Ah okay, should have googled it. Thank You.