PDA

View Full Version : Need a little help with QThread



Slewman
5th March 2010, 19:41
so i have a class that is used to upload and download files from an ftp server.

The class inherits QThread, so i initialize my ftp class in my constructor, then when i try to do a save/download i first do this



sftp.start(QThread::NormalPriority);
sftp.get(filename);
sftp.terminate();


that doesnt seem to work, my program locks up when i download the file, and of course, once i get the file, the program resumes.

I then tried to initialize the ftp class in my constructor then immediately after initializing i call a


sftp.start(QThread::NormalPriority);


i call my gets/sends then at the de-constructor of the class i call



sftp.terminate();


i saw the same behavior. anyone have any suggestions?

Slewman
15th March 2010, 17:07
anyone have any suggestions?

squidge
15th March 2010, 17:46
The constructor is run in the same thread as the calling thread, so you need to put the code that takes the time into the run method of the thread.

Slewman
15th March 2010, 17:55
I dont quite understand what you mean. where should i call a start on my new thread?

norobro
15th March 2010, 20:04
Here is what he means: http://doc.qt.nokia.com/4.6/qthread.html#details