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";
Thanks.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With