PDA

View Full Version : problem with QtConcurrent::run



etognoni
30th March 2012, 11:34
How to run:



QFuture <void> future = QtConcurrent::run(client);


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




main.cpp
...
Client client;
QFuture <void> future = QtConcurrent::run(client);
....

file.h
....
class Client: public QObject
{
Q_OBJECT
public:
Client(QObject* parent = 0);
~Client();
void start(QString address, quint16 port);

public slots:
void startTransfer();

private:
QTcpSocket client;
};
....

Lykurg
30th March 2012, 12:09
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.

stampede
4th April 2012, 23:14
If you want to run a member method of a class instance, check in the documentation:
QtConcurrent::Run - using member functions (http://qt-project.org/doc/qt-4.8/qtconcurrentrun.html#using-member-functions)