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 compile errors

QtConcurrent compile errors

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 2.2k Views
  • 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.
  • M Offline
    M Offline
    mehr
    wrote on 11 Oct 2021, 19:12 last edited by
    #1

    Hi,
    I am a new to Qt and first time usng QtConcurrent and getting lots of errors:(
    I have done the "QT += concurrent" in the .pro file.
    I also tried a func param and still similar errors.

    Any clues?
    Thanks!

    void Floor::upPressed(){
    ...
    FlrReq flrReq(flr, true);
    QFuture<int> future = QtConcurrent::run(this, &Floor::runFloorRequest, flrReq);

    int res = future.result();
    

    }

    int Floor::runFloorRequest(FlrReq req)
    {
    std::cout << "flrNum: " << req.getFloorNum() << " dir:" << req.getDir();
    return 0;
    }

    In file included from C:/Qt/6.2.0/mingw81_64/include/QtCore/qfuture.h:48,
    from C:/Qt/6.2.0/mingw81_64/include/QtCore/qcoreapplication.h:49,
    from C:/Qt/6.2.0/mingw81_64/include/QtCore/qcommandlineparser.h:45,
    from C:/Qt/6.2.0/mingw81_64/include/QtCore/QtCore:54,
    from C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/QtConcurrentDepends:3,
    from C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/QtConcurrent:3,
    from ..\Comp3004A2\floor.h:11,
    from ..\Comp3004A2\floor.cpp:1:
    C:/Qt/6.2.0/mingw81_64/include/QtCore/qfuture_impl.h: In instantiation of 'struct QtPrivate::ArgResolver<Floor*>':
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h:224:1: required from 'struct QtConcurrent::PromiseTaskResolver<Floor*, int (Floor::)(FlrReq), FlrReq>'
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h:247:8: required from 'struct QtConcurrent::TaskResolverHelper<std::integral_constant<bool, false>, Floor
    , int (Floor::)(FlrReq), FlrReq>'
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h:253:8: required from 'struct QtConcurrent::TaskResolver<Floor
    , int (Floor::)(FlrReq), FlrReq>'
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentrun.h:82:76: required from 'auto QtConcurrent::run(QThreadPool
    , Function&&, Args&& ...) [with Function = Floor*; Args = {int (Floor::)(FlrReq), FlrReq&}]'
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentrun.h:99:15: required from 'auto QtConcurrent::run(Function&&, Args&& ...) [with Function = Floor
    ; Args = {int (Floor::)(FlrReq), FlrReq&}]'
    ..\Comp3004A2\floor.cpp:93:82: required from here
    C:/Qt/6.2.0/mingw81_64/include/QtCore/qfuture_impl.h:168:43: error: 'operator()' is not a member of 'std::decay<Floor
    >::type' {aka 'Floor*'}
    struct ArgResolver : ArgResolver<decltype(&std::decay_t<F>::operator())>
    ^~~~
    In file included from C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtaskbuilder.h:45,
    from C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/QtConcurrent:4,
    from ..\Comp3004A2\floor.h:11,
    from ..\Comp3004A2\floor.cpp:1:
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h: In instantiation of 'struct QtConcurrent::PromiseTaskResolver<Floor*, int (Floor::)(FlrReq), FlrReq>':
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h:247:8: required from 'struct QtConcurrent::TaskResolverHelper<std::integral_constant<bool, false>, Floor
    , int (Floor::)(FlrReq), FlrReq>'
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h:253:8: required from 'struct QtConcurrent::TaskResolver<Floor
    , int (Floor::)(FlrReq), FlrReq>'
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentrun.h:82:76: required from 'auto QtConcurrent::run(QThreadPool
    , Function&&, Args&& ...) [with Function = Floor*; Args = {int (Floor::)(FlrReq), FlrReq&}]'
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentrun.h:99:15: required from 'auto QtConcurrent::run(Function&&, Args&& ...) [with Function = Floor
    ; Args = {int (Floor::)(FlrReq), FlrReq&}]'
    ..\Comp3004A2\floor.cpp:93:82: required from here
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h:224:1: error: no type named 'IsPromise' in 'struct QtPrivate::ArgResolver<Floor
    >'
    {
    ^
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h: In instantiation of 'static auto QtConcurrent::PromiseTaskResolver<Function, Args ...>::run(QtConcurrent::PromiseTaskResolver<Function, Args ...>::TaskWithArgs&&, const QtConcurrent::TaskStartParameters&) [with Function = Floor*; Args = {int (Floor::)(FlrReq), FlrReq}; QtConcurrent::PromiseTaskResolver<Function, Args ...>::TaskWithArgs = std::tuple<Floor, int (Floor::)(FlrReq), FlrReq>; typename std::decay<_Tp>::type = Floor]':
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentrun.h:82:76: required from 'auto QtConcurrent::run(QThreadPool*, Function&&, Args&& ...) [with Function = Floor*; Args = {int (Floor::)(FlrReq), FlrReq&}]'
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentrun.h:99:15: required from 'auto QtConcurrent::run(Function&&, Args&& ...) [with Function = Floor
    ; Args = {int (Floor::)(FlrReq), FlrReq&}]'
    ..\Comp3004A2\floor.cpp:93:82: required from here
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h:231:83: error: no type named 'PromiseType' in 'struct QtPrivate::ArgResolver<Floor
    >'
    using PromiseType = typename QtPrivate::ArgResolver<Function>::PromiseType;
    ^
    C:/Qt/6.2.0/mingw81_64/include/QtConcurrent/qtconcurrentstoredfunctioncall.h:232:17: error: no type named 'PromiseType' in 'struct QtPrivate::ArgResolver<Floor*>'
    return (new StoredFunctionCallWithPromise<Function, PromiseType, Args...>(std::move(args)))
    ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ..\Comp3004A2\floor.cpp: In member function 'void Floor::upPressed()':
    ..\Comp3004A2\floor.cpp:93:44: error: conversion from 'void' to non-scalar type 'QFuture<int>' requested
    QFuture<int> future = QtConcurrent::run(this, &Floor::runFloorRequest, flrReq);
    ~^~~~~~~~~~~~~~~~~~~~~~~

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 11 Oct 2021, 19:34 last edited by
      #2

      Hi and welcome to devnet,

      QtConcurent run is usually not called on an instance of the object you want to apply run on.

      Another issue here is that the way you use it makes the call to run overkill since you are directly waiting for the result and thus blocking the execution.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply 13 Oct 2021, 00:44
      0
      • J Offline
        J Offline
        Jonas Kvinge
        wrote on 11 Oct 2021, 19:46 last edited by
        #3

        @mehr said in QtConcurrent compile errors:

        QFuture<int> future = QtConcurrent::run(this, &Floor::runFloorRequest, flrReq);

        In Qt 6 this should be:

        QFuture<int> future = QtConcurrent::run(&Floor::runFloorRequest, this, flrReq);
        
        0 1 Reply Last reply 22 Jul 2022, 22:10
        2
        • S SGaist
          11 Oct 2021, 19:34

          Hi and welcome to devnet,

          QtConcurent run is usually not called on an instance of the object you want to apply run on.

          Another issue here is that the way you use it makes the call to run overkill since you are directly waiting for the result and thus blocking the execution.

          M Offline
          M Offline
          mehr
          wrote on 13 Oct 2021, 00:44 last edited by
          #4

          @SGaist Thanks!
          Actually the solution posted by Jonas below fixed it.

          1 Reply Last reply
          0
          • J Jonas Kvinge
            11 Oct 2021, 19:46

            @mehr said in QtConcurrent compile errors:

            QFuture<int> future = QtConcurrent::run(this, &Floor::runFloorRequest, flrReq);

            In Qt 6 this should be:

            QFuture<int> future = QtConcurrent::run(&Floor::runFloorRequest, this, flrReq);
            
            0 Offline
            0 Offline
            0x4D6F652E51
            wrote on 22 Jul 2022, 22:10 last edited by
            #5

            thanks @Jonas-Kvinge ... I've spent hours trying to solve this!

            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