How to Convert QBuffer to QString

You can convert QBuffer to QString using buffer function of the QBuffer. Here is how you can do it.

QBuffer b;
b.open(QBuffer::ReadWrite);
b.write("http://amin-ahmadi.com");
QString str = b.buffer();
qDebug() << str; // "http://amin-ahmadi.com"
b.close();


How to convert QString to C String (char *)

The best solution for this would be to go through standard C++ and it means this:

Let’s say you have a QString, like this:

QString s = "www.amin-ahmadi.com";

First convert it to std::string and then use its c_str method, like this:

s.toStdString().c_str()