After a lot of try and error, mostly error and crashes, i ended up with this working solution:
foreach(FTPDownload* w, g_Worker)
{
if(w->_working)
{
w->abort(); // sets _working = false and _abort = true
w->ftp->deleteLater(); // ends the QFtp download
w->thread()->quit();
w->thread()->deleteLater();
}
}
The only problem left is when i remove the table from the QTableView the progress update wont terminate and the app crashes, because the table does not exist anymore.
I guess i have to add the the function that executes the code from above somehow in a event loop so the code after that deletes the table wont be executed before all the downloads are really stopped. Right?