c++ - Converting QString to std::string -


i've seen several other posts converting qstring std::string, , should simple. somehow i'm getting error.

my code compiled vs project using cmake (i'm using vs express), there's no issue qt libraries, , gui wrote works besides part.

i have qcombobox cb holds names objects, , qlineedit lineedit allows me specify name of object looking for. should run function tested , working when press go button, input qcombobox , lineedit arguments.

here's code when go button clicked:

void gui::on_go_clicked(){     std::string str(cb->currenttext().tostdstring());     //std::cout << str << "\n";     //qstring qstr = lineedit->text();     //std::cout<<lineedit->text().tostdstring();     updatedb(str, lineedit->text().tostdstring()); } 

the first line, creating str, works fine. i.e. there's no problem library functions or tostdstring(). when executes function, program breaks, , it's not becuase of function, it's because of part tries convert lineedit->text().tostdstring().

this when write word "test" in lineedit box. i've seen other answers talking unicode, tried briefly, can assume user not putting special characters in lineedit box, barring '_' , '.', shouldn't unicode.

the first line, creating str, works fine. i.e. there's no problem library functions or tostdstring(). when executes function, program breaks, , it's not becuase of function, it's because of part tries convert lineedit->text().tostdstring().

simplify test , verify qstring.tostdstring() expect:

therefore:

qstring text = "precise text user input"; std::cout << text.tostdstring() << std::endl; //or... qdebug() << text.tostdstring().c_str(); 

is expected result produced?

if case, means function has problem. how updatedb (function signature?)? inputs?

from qt files:

the unicode data converted 8-bit characters using toutf8() function.

therefore, if haven't changed locale of widget (lineedit) or it's parents, things should work (or should see information loss). i've used function many times without trouble...


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -