PDA

View Full Version : Problem with MultiThread..



blm
12th September 2008, 15:47
i have made out a thread for data processing,

I want to read a series data (QPointF) from local harddisk,once a new data comes then tell the main thread to draw the new point,
signal:
newDataCome(QPointF newpoint);

there are nothing like QMutex, QReadWriteLock, QWaitCondition in the qthread ,

than a made a extern object of thread

extern ProcessThread processthread;

but after building there is a error by this row:
connect(&processthread, SIGNAL(newDataCome(QPointF)), this, SLOT(paintNewPoint(QPoint)));

and the error code is:
undefined reference to `_processthread`

i don`t unterstand what is a _processthread?:confused:

thanks for your help!!

jpn
12th September 2008, 16:20
Where do you declare the actual variable? "extern" means that the variable is available in a different translation unit. Anyway, I'd recommend not to use global variables at all. Why not just declare it as a member variable of some class which manages the thread?

blm
15th September 2008, 10:53
Where do you declare the actual variable? "extern" means that the variable is available in a different translation unit. Anyway, I'd recommend not to use global variables at all. Why not just declare it as a member variable of some class which manages the thread?
thanks,

in a header file i have declared the Qthread class,
processthread.h

the ProcessThread is used for dataprocess, and will be involked by many instances, so is a "extern"

anyway i don`t unterstand, where come from the "_processthread" ??

blm
15th September 2008, 11:05
new error,
now i declare the processthread as a member variable ,

but the error description is changed as follows:

field`processthread`has incomplete type,

what`s meas for that?

tone
15th September 2008, 11:06
Could you post some minimal code example that might aid to understand what the problem is?

cheers,
--to

jpn
15th September 2008, 11:11
new error,
now i declare the processthread as a member variable ,

but the error description is changed as follows:

field`processthread`has incomplete type,

what`s meas for that?

#include <QThread>

blm
15th September 2008, 11:48
at last i find a solution,

previous i write
#include "processthread.h"
in Plotter.cpp

now i write it in Plotter.h,
and declared the processthread class as a member variable in Plotter.

but i still don`t unterstand what`s the difference