PDA

View Full Version : QtConcurrentRun and global function



hakermania
16th July 2011, 09:03
Hello, I am having some global functions in a separate glob.h file included in the *.cpp files that need to use these functions...
My question is, how can I start one of these global functions using qtconcurrentrun while these functions don't have a parent?
For example, for a normal use, I would call


QtConcurrent::run(this, &MainWindow::my_function);

But the global function isn't in 'this' object and doesn't have a class (like MainWindow)...
I tried with NULL instead of 'this' and simply function's name as second argument...

I am not sure who to use it.... Anybody with an idea :D ?

stampede
16th July 2011, 09:14
Why not like this:


void someFunction(){
...
}

QFuture<void> f = QtConcurrent::run(someFunction);

Its in the docs (http://doc.qt.nokia.com/latest/qtconcurrentrun.html) :)

hakermania
16th July 2011, 10:05
It was that simple :P Thanks :)