Oh sorry, caduel, I have confused you. I first tried with QtConcurrent then I tried with QThread. Let me show you some code...
Here is the line that will call the function:
QtConcurrent::run(this,&MidpointSceneThread::getMidpoints,myStruct)
QtConcurrent::run(this,&MidpointSceneThread::getMidpoints,myStruct)
To copy to clipboard, switch view to plain text mode
where myStruct is a bunch of data I need in the function.
defined as:
struct MidpointStruct {
QList<ShotGraphicsItem *> sgiList;
GeometryVersion *gvLocal;
int startIndex;
int size;
int decimateBy;
MidpointGraphicsLayer * mpgl;
};
struct MidpointStruct {
QList<ShotGraphicsItem *> sgiList;
GeometryVersion *gvLocal;
int startIndex;
int size;
int decimateBy;
QImage image;
MidpointGraphicsLayer * mpgl;
};
To copy to clipboard, switch view to plain text mode
ShotGraphicsItem and MidpointGraphicsLayer are types of QGraphicsItems,
declaration of function (it is a part of the class MidpointSceneThread):
QPolygonF MidpointSceneThread
::getMidpoints(MidpointStruct
&myStruct
);
QPolygonF MidpointSceneThread::getMidpoints(MidpointStruct &myStruct);
To copy to clipboard, switch view to plain text mode
This function goes through the list of ShotGraphicsItems and does some calculations and returns a set of points (Midpoints) that I use to draw on a pixmap.
The issue is I want the list of ShotGraphicsItem to be broken up and I tried several things to get the future return items...
I tried making a loop and calling the run function 3 times...
More CODE:
for (int ndx = 0; ndx < numThreads; ++ndx){
QFuture<QPolygonF> midpoints[ndx] = QtConcurrent::run(this,&MidpointSceneThread::getMidpoints,myStruct[ndx]);
}
for (int ndx = 0; ndx < numThreads; ++ndx){
QFuture<QPolygonF> midpoints[ndx] = QtConcurrent::run(this,&MidpointSceneThread::getMidpoints,myStruct[ndx]);
}
To copy to clipboard, switch view to plain text mode
Is this even a proper way to split up the job? when I run this and call :
for (int ndx = 0; ndx < numThreads; ++ndx)
resultPoly[ndx] = midpoints[ndx].result();
for (int ndx = 0; ndx < numThreads; ++ndx)
resultPoly[ndx] = midpoints[ndx].result();
To copy to clipboard, switch view to plain text mode
I get the first one but the loop does not get the other 2 results and only part of the map is drawn.
I hope this makes it clearer what I'm asking.
JW
Bookmarks