If Qt is built with STL support than it should work by default, you don't need to add anything in .pro file or anywhere else.
But you can't use std::string instead QString, you will need to convert it to QString to use it in widgets (or any other Qt library function that takes a QString)
Check this example:
#include <QApplication>
#include <QLabel>
#include <string>
int main(int argc, char** argv) {
std::string hello = "Hello World!";
l.
setText(QString::fromStdString(hello
));
l.show();
return a.exec();
}
#include <QApplication>
#include <QLabel>
#include <string>
int main(int argc, char** argv) {
QApplication a(argc, argv);
std::string hello = "Hello World!";
QLabel l;
l.setText(QString::fromStdString(hello));
l.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks