Results 1 to 3 of 3

Thread: QtConcurrentRun and global function

  1. #1
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation QtConcurrentRun and global function

    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
    Qt Code:
    1. QtConcurrent::run(this, &MainWindow::my_function);
    To copy to clipboard, switch view to plain text mode 
    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 ?
    When you 're trying to help somebody in the newbie section, don't forget that he is a newbie. Be specific and give examples.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QtConcurrentRun and global function

    Why not like this:
    Qt Code:
    1. void someFunction(){
    2. ...
    3. }
    4.  
    5. QFuture<void> f = QtConcurrent::run(someFunction);
    To copy to clipboard, switch view to plain text mode 
    Its in the docs
    Last edited by stampede; 16th July 2011 at 10:15. Reason: corrected link

  3. The following user says thank you to stampede for this useful post:

    hakermania (16th July 2011)

  4. #3
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QtConcurrentRun and global function

    It was that simple :P Thanks
    When you 're trying to help somebody in the newbie section, don't forget that he is a newbie. Be specific and give examples.

Similar Threads

  1. QML Global Object
    By coderbob in forum Qt Quick
    Replies: 1
    Last Post: 3rd November 2010, 14:18
  2. Replies: 2
    Last Post: 13th September 2010, 21:03
  3. Replies: 3
    Last Post: 25th May 2010, 10:46
  4. Replies: 0
    Last Post: 10th March 2010, 09:13
  5. global variable
    By Shuchi Agrawal in forum General Programming
    Replies: 10
    Last Post: 15th February 2007, 05:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.