[Qt-interest] Using boost to bind function for QtConcurrent::run()

Cole, Derek dcole at integrity-apps.com
Tue Jul 12 17:13:13 CEST 2011


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?

Thanks!
________________________________
From: qt-interest-bounces+dcole=integrity-apps.com at qt.nokia.com [qt-interest-bounces+dcole=integrity-apps.com at qt.nokia.com] on behalf of Cole, Derek [dcole at integrity-apps.com]
Sent: Tuesday, July 12, 2011 10:29 AM
To: qt-interest at qt.nokia.com
Subject: [Qt-interest] Using boost to bind function for QtConcurrent::run()

Hello,

I am trying to bind a function that requires more than 5 arguments, so that I can use it with QtConcurrent::run()

This line on its own compiles:

 boost::bind(&GDALDriver::CreateCopy,poNITFDriver, pszDstFilename, poDataset, FALSE,  papszOptions, pfnProgress, progMessage);

Where poNITFDriver is an instance of GDALDriver and has a CreateCopy method.

This line fails to compile:

    future = QtConcurrent::run( boost::bind(&GDALDriver::CreateCopy,poNITFDriver, pszDstFilename, poDataset, FALSE,  papszOptions, pfnProgress, progMessage));

with the error message:

error: no match for operator= in future = QtConcurrent::run(FunctionObject) [with FunctionObject = boost::_bi::bind_t<GDALDataset*, boost::_mfi::mf6<GDALDataset*, GDALDriver, const char*, GDALDataset*, int, char**, int (*)(double, const char*, void*), void*>, boost::_bi::list7<boost::_bi::value<GDALDriver*>, boost::_bi::value<const char*>, boost::_bi::value<GDALDataset*>, boost::_bi::value<bool>, boost::_bi::value<char**>, boost::_bi::value<int (*)(double, const char*, void*)>, boost::_bi::value<char*> > >]()

What am I doing wrong here?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110712/d0f6b05f/attachment.html 


More information about the Qt-interest-old mailing list