How do i define std::string as a type so i can emit from text from a QThread to another using a queued connection?
I searched and found many threads solving this issue.
Here one of the other threads available
But all of them consider the connection as a Qt 4 version. (Signal and slot macros).
Now, after 3 years, with Qt5.2 available, i'm not able to find a solution, even when the documentation says:
I have to define the type in my header. I tried where Q_OBJECT goes, and outside the class. Apparently outside works.
I tried:
Q_DECLARE_METATYPE<std::string>();
Q_DECLARE_METATYPE(std::string);
Q_DECLARE_METATYPE<std::string>;
Q_DECLARE_METATYPE<std::string>(anothername declared for std::string with typedef);
All of them gave me errors, from: Syntax error : missing ';' before , to unnable to missing type specifier, int assumed. The problem is always with this line of code.
and i´m using this in the same class within a method, which registers the type just before connecting the new thread with a queued connection:
qRegisterMetaType<std::string>();
QObject::connect(worker, &Raytracer::textEmitted, gui_, &MainWindow::addText, Qt::QueuedConnection);
What am i doing wrong?
I got to make it work by using QString. But how could i make it work with std::string?