
Originally Posted by
high_flyer
Have one thread call the stages one aftter the other, instead of putting each stage in its own thread.
thanks so much
while i was waiting for a reply to my thread, this was exact same approach i tried, but i came across a problem,
now instead of having different threads in one loop, i have loop in one thread. Below is code for it followed by description of issue i am facing:
ItemList::ItemList()
{
cObj *_cobj;
_cobj=new cObj("arguments passed to constructor");
_cobj.properties="set properties and stuffs";
list.append(_cobj); //QVector object of 'cObj' type
_cobj=new cObj("diffr");
_cobj.properties="properties for this instance";
list.append(_cobj); //QVector object of 'cObj' type
createThread(); // to create thread...definition is below
ItemList::ItemList()
{
cObj *_cobj;
_cobj=new cObj("arguments passed to constructor");
_cobj.properties="set properties and stuffs";
list.append(_cobj); //QVector object of 'cObj' type
_cobj=new cObj("diffr");
_cobj.properties="properties for this instance";
list.append(_cobj); //QVector object of 'cObj' type
createThread(); // to create thread...definition is below
To copy to clipboard, switch view to plain text mode
void ListObj::createThread()
{
cObj _cObj1=_cObjGLOBAL;
_cObj1->moveToThread(thread);
cObj1->connect(thread,SIGNAL(started()),SLOT(startProcess())); //<<--------------------- This line
thread.connect(&thread,SIGNAL(finished()),&thread,SLOT(quit()));
thread.start();
thread.wait();
}
void ListObj::startProcess() //<<------------------------ REFERENCE1
{
for (i=0;i< list.count(); i++)
{
//process for each iteration
}
}
void ListObj::createThread()
{
QThread *thread=new QThread;
cObj _cObj1=_cObjGLOBAL;
_cObj1->moveToThread(thread);
cObj1->connect(thread,SIGNAL(started()),SLOT(startProcess())); //<<--------------------- This line
thread.connect(&thread,SIGNAL(finished()),&thread,SLOT(quit()));
thread.start();
thread.wait();
}
void ListObj::startProcess() //<<------------------------ REFERENCE1
{
for (i=0;i< list.count(); i++)
{
//process for each iteration
}
}
To copy to clipboard, switch view to plain text mode
NOW problem is where above code lies "This line"... actually connect() looks for startProcess() in cObj, but i want reference to "REFERENCE1", i have tried following:
cObj1->connect(thread,SIGNAL(started()),this,SLOT(startProcess())); //<<----------with "this" as *receiver
cObj1->connect(thread,SIGNAL(started()),this,SLOT(startProcess())); //<<----------with "this" as *receiver
To copy to clipboard, switch view to plain text mode
but it gave me compile error:
no matching function for call to ‘_cObj::connect(QThread*&, const char*, ListObj* const, const char*)’

Originally Posted by
naturalpsychic
but it gave me compile error:
no matching function for call to ‘_cObj::connect(QThread*&, const char*, ListObj* const, const char*)’
Oh oki i have overcome this problem by looking at original signature of connect()...since my ListObj doesn't inherit QObject so it is not considered as QObject, what i did i inherited QObject and now everything is working all good...
Thanks alot guys
Bookmarks