Results 1 to 3 of 3

Thread: problem with QtConcurrent::run

  1. #1
    Join Date
    Mar 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default problem with QtConcurrent::run

    How to run:

    Qt Code:
    1. QFuture <void> future = QtConcurrent::run(client);
    To copy to clipboard, switch view to plain text mode 

    error: no matching function for call to 'run(Client&, int)'
    I cant find the good way to declare class Client, client(), param... , arg....


    Qt Code:
    1. main.cpp
    2. ...
    3. Client client;
    4. QFuture <void> future = QtConcurrent::run(client);
    5. ....
    6.  
    7. file.h
    8. ....
    9. class Client: public QObject
    10. {
    11. Q_OBJECT
    12. public:
    13. Client(QObject* parent = 0);
    14. ~Client();
    15. void start(QString address, quint16 port);
    16.  
    17. public slots:
    18. void startTransfer();
    19.  
    20. private:
    21. QTcpSocket client;
    22. };
    23. ....
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: problem with QtConcurrent::run

    QtConcurrent::run() expects a function, not a class. Furthermore doing networking in a thread isn't such a good idea. The network classes of Qt are already threaded.

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

    Default Re: problem with QtConcurrent::run

    If you want to run a member method of a class instance, check in the documentation:
    QtConcurrent::Run - using member functions

Similar Threads

  1. setHtml and QtConcurrent problem
    By andrepimenta in forum Qt Programming
    Replies: 1
    Last Post: 1st January 2012, 20:06
  2. Problem with QtConcurrent::run
    By januszmk in forum Newbie
    Replies: 5
    Last Post: 30th July 2011, 17:57
  3. qtconcurrent
    By knishaq in forum Qt Programming
    Replies: 4
    Last Post: 15th December 2009, 08:41
  4. QtConcurrent question
    By bair in forum Qt Programming
    Replies: 5
    Last Post: 24th March 2009, 10:46
  5. QtConcurrent
    By Brandybuck in forum An Introduction to QThreads
    Replies: 2
    Last Post: 9th May 2008, 14:10

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.