Hi,
I've the following question:
Why don't we be able to use a member function jointly with QtConcurrent or QThread? Why must be a standalone function?
Thanks
Hi,
I've the following question:
Why don't we be able to use a member function jointly with QtConcurrent or QThread? Why must be a standalone function?
Thanks
It can be a member function as well but it has to be a member function of a class that is carried in the container passed to QtConcurrent. Otherwise than that only static member functions and non-member functions may be used. This is caused by the fact that it is not possible to specify a "pointer to a function of any class" in C++.
Hi Wysota,
Thanks a lot, now I understand.
Bye
I am not sure if I understood the OP's question correctly.
You can use member functions for some things, e.g. with QtConcurrent::mapped, if you wrap them with Boost.Bind or something similar.
Example from Qt docs:
Qt Code:
QList<QImage> images = ...; QFuture<QImage> thumbnails = QtConcurrent::mapped(images, boost::bind(&QImage::scaledToWidth, 100 Qt::SmoothTransformation));To copy to clipboard, switch view to plain text mode
HTH
Hi Caduel,
yes something as:
class TEST
{
public:
TESTE();
void funct();
};
TESTE test;
QList<QImage> images = ...;
QFuture<QImage> thumbnails = QtConcurrent::mapped(images, test.funct(&QImage::scaledToWidth, 100 Qt::SmoothTransformation));
Now I understand that isn't possible. I must be use static functions for example.
Like the Wysota explained me
your example is confusing... a function returning void does not make sense with "mapping".
something like that should work. (Haven't tried it.)Qt Code:
class TEST { public: TESTE(); }; TESTE test; QLis<QString> files = ...; QFuture<QImage> pics = QtConcurrent::mapped(files, boost::bind(&TEST::func, &test));To copy to clipboard, switch view to plain text mode
Sorry,
I know about this.
Your example this ok.
Thanks for your help
Bookmarks