Convert std::string to QString

I've got an std::string content that I know contains UTF-8 data. I want to convert it to a QString. How do I do that, avoiding the from-ASCII conversion in Qt?

Answers


There's a QString function called fromUtf8 that takes a const char*:

QString str = QString::fromUtf8(content.c_str());

Need Your Help

Apply XOR operator in a lambda function

php function xor

My issue is a bit haywire, I must admit before I carry on. So please do not ask me why I need this. Here goes:

Design pattern to represent CSV file as a data structure

java design-patterns design csv

I am writing a Java class to take a CSV file and do various statistical operations on values in it, and then write the result to XML. I need a data structure to hold the data between the reading fr...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.