Good day.
Began to learn threads for 11 standard in Qt!
Here I have a simple code:
#include <QCoreApplication> #include <thread> #include <iostream> using namespace std; void func(); int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); MyThread th1; th1.run(); return a.exec(); } void func() { cout << "This string from thread!"<<endl; } So, on the second line (the thread library) the compiler swears, they say, does not know this.
I read that you need in the file with the .pro extension to add CONFIG += c++11 . Finished, but nothing has changed!
Tell me please.
Update
#include <QDebug> #include <QCoreApplication> #include <iostream> #include <QThread> void foo() { std::cout << "This string from thread!"<<endl; } int main(int argc, char *argv[]) { QApplication a(argc, argv); std::thread t(foo); std::t.join(); return a.exec(); } Why does the compiler swear?