[Qt-interest] Using boost to bind function for QtConcurrent::run()
Bo Thorsen
bo at fioniasoftware.dk
Tue Jul 12 19:50:34 CEST 2011
Den 12-07-2011 17:13, Cole, Derek skrev:
> In the original code, I had declared future and watcher like so:
> QFutureWatcher<GDALDataset> watcher;
> QFuture<GDALDataset> future;
>
>
>
> It appears that if I change that to
>
> QFuture<void> future1 = QtConcurrent::run(
> boost::bind(&GDALDriver::CreateCopy,poNITFDriver, pszDstFilename,
> poDataset, FALSE, papszOptions, pfnProgress, progMessage));
>
> where I set the return type as void, this will compile and run the
> method properly.
>
> However, the CreateCopy() method is supposed to return a reference to a
> GDALDataset, so how can I now get to this returned object, when using boost?
Create a struct like this:
struct Args {
GDALDataset* returnValue;
// Other args here ...
};
And store that. Then you can create a function that only takes a pointer
to this struct and let that call the real work function and store the
return value.
Bo Thorsen,
Fionia Software.
--
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
More information about the Qt-interest-old
mailing list