Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtConcurrent QSettings parameter
Forum Updated to NodeBB v4.3 + New Features

QtConcurrent QSettings parameter

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zenwong
    wrote on last edited by
    #1

    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);@

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      -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.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andreyc
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          Correction: class QSettings explicitly disables a copy constructor.

          in qsettings.h
          @
          class Q_CORE_EXPORT QSettings : public QObject
          {
          ...
          private:
          Q_DISABLE_COPY(QSettings)
          };
          @

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved