PDA

View Full Version : Creating object of other class in Run() method



santosh.kumar
15th May 2007, 14:55
hi

I m using recursivly loading directory method in Run() function of QThread.
i m giving definiton of this method in other class and displaying in treeWidget.
when i m calling this method using object of this class in Run() method

#include "otherclass.h"
void class::threadFunc()
{
////
}
void class::Run()
{
otherclass *obj = NULL;
obj = new otherclass;
while(!bFalse)
{
obj->method(QString path);
}
}

///
class obj;
void otherclass::fun()
{
obj.threadFunc();
}


can u give me suggestions that why this happens..i m creating thread obj in other class and other class obj in thread class....i m confusing...it is giving error....how i use the other class function in Run() method....

marcel
15th May 2007, 14:59
What error?
Isn't this a double post?( wysota is gonna get so mad... :) )

Anyways, make sure you don't create/modify GUI objects in the worker thread.
Regards

jpn
15th May 2007, 15:05
Isn't this a double post?( wysota is gonna get so mad... :) )
More like a pentuple thread :)

http://www.qtcentre.org/forum/f-qt-programming-2/t-creating-object-of-other-class-in-run-method-7063.html
http://www.qtcentre.org/forum/f-qt-programming-2/t-calling-recursivly-loading-function-in-run-method-of-qthread-7062.html
http://www.qtcentre.org/forum/f-qt-programming-2/t-thread-implementing-and-stopping-the-thread-7028.html
http://www.qtcentre.org/forum/f-qt-programming-2/t-stop-the-thread-during-recursivly-loading-directory-7025.html
http://www.qtcentre.org/forum/f-qt-programming-2/t-stop-the-thread-7020.html


Please DO NOT start new threads again and again on the same subject!