Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert bool to QString

Tags:

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.

like image 808
Jjreina Avatar asked Mar 07 '12 15:03

Jjreina


1 Answers

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); 
like image 159
tmpearce Avatar answered Sep 22 '22 22:09

tmpearce