A concurrent function run problem.
-
I try to run a function.
void SENSOR::DiscoverConcurrent(uint32_t count) { QFuture<void> future = QtConcurrent::run(SENSOR::DiscoverByIndexAll, count); }
But I get this error - error: reference to non-static member function must be called.
What does it means. The functionvoid SENSOR::DiscoverByIndexAll(uint32_t count) {]
Is not static - I can call it from other modules.
-
I try to run a function.
void SENSOR::DiscoverConcurrent(uint32_t count) { QFuture<void> future = QtConcurrent::run(SENSOR::DiscoverByIndexAll, count); }
But I get this error - error: reference to non-static member function must be called.
What does it means. The functionvoid SENSOR::DiscoverByIndexAll(uint32_t count) {]
Is not static - I can call it from other modules.
@jenya7 said in A concurrent function run problem.:
Is not static - I can call it from other modules.
right its not static, therefore it requires an instance pointer.
this
in this case -
@jenya7 said in A concurrent function run problem.:
Is not static - I can call it from other modules.
right its not static, therefore it requires an instance pointer.
this
in this case -
@J-Hilk
void SENSOR::DiscoverConcurrent(uint32_t count) { QFuture<void> future = QtConcurrent::run(this->DiscoverByIndexAll, count); }
the same error
-
QFuture<void> future = QtConcurrent::run(this, &SENSOR::DiscoverByIndexAll, count);
@J-Hilk said in A concurent function run problem.:
this, &SENSOR::DiscoverByIndexAll, count
Thank you. And how can I call the function concurrently from other module?
-
QFuture<void> future = QtConcurrent::run(this, &SENSOR::DiscoverByIndexAll, count);
@J-Hilk said in A concurrent function run problem.:
QFuture<void> future = QtConcurrent::run(this, &SENSOR::DiscoverByIndexAll, count);
@J-Hilk is right. This is documented at https://doc.qt.io/qt-5/qtconcurrentrun.html#using-member-functions
-
@J-Hilk said in A concurent function run problem.:
this, &SENSOR::DiscoverByIndexAll, count
Thank you. And how can I call the function concurrently from other module?
@jenya7 said in A concurrent function run problem.:
And how can I call the function concurrently from other module?
In the same way, just pass pointer to SENSOR instance instead of this...
-
@jenya7 said in A concurrent function run problem.:
And how can I call the function concurrently from other module?
In the same way, just pass pointer to SENSOR instance instead of this...