QtConcurrent QSettings parameter
-
I'm trying to pass a QSettings to a function being run by QtConcurrent::run, and I am getting this error
@/usr/include/qt/QtConcurrent/qtconcurrentstoredfunctioncall.h:609: error: call to deleted constructor of 'QSettings'
: fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ }
^ ~~~~~@I'm running it like this:
@QFuture<void> future = QtConcurrent::run(worker, &Worker::doImport, db, settings);
vidsWatcher.setFuture(future);@Prototype:
@void Worker::doImport(QSqlDatabase db, const QSettings& settings);@ -
-Is it possible that you pass local QSettings variable as a parameter of QtConcurrent::run()?-
-If so that your variable maybe deleted when doImport() is executed.-
The staement and questions above are wrong because it is a compile time error, not run time.Edited later.
-
Another option is that QSettings does not have a copy constructor.
The call @QFuture<void> future = QtConcurrent::run(worker, &Worker::doImport, db, settings);@
comes to
@
VoidStoredMemberFunctionPointerCall2(T (Class::*_fn)(Param1, Param2) , Class *_object, const Arg1 &_arg1, const Arg2 &_arg2)
: fn(_fn), object(_object), arg1(_arg1), arg2(_arg2){ }
@where arg1 and arg2 are created using the copy constructors.
So you need to create a class with a copy constructor and pass it as an argument. In that class copy constructor you will copy QSettings.