I want convert bool to QString.
Whats the most efficient way to do it?, This is my code but sure that there is other way better.
bool test = true;
test ? "1" : "0";
You can use the static QString::number
method - the bool will be implicitly cast to int to match the integer form of the static factory method, which returns a QString
containing 0
or 1
.
bool test = true;
QString s = QString::number(test);