Home > Programare > Conversia de stringuri QString <--> std::string

Conversia de stringuri QString <--> std::string

M-am lovit de conversia de stringuri intre QString si std::string. Iata cum se face cel mai usor:

Conversia std:string la QString se face folosind constructorul:

std::string std_string = “standard string”;

QString q_string( std_string );
QString q_string2 = QString(std_string);

Conversia inversa ( de la QString  la str_string ) se face folosind metodele latin1() sau ascii() deoarece constructorul std::string accepta char* ca parametru:

std::string std_string2 = q_string.latin1();

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks:0

Listed below are links to weblogs that reference
Conversia de stringuri QString <--> std::string from Cop Online
TOP