Here's some test code:
QString qstr_test("TEST");
const char *p = qstr_test.toStdString().c_str();
cout << p << endl;
Nothing is output as p is an empty string.
Here's what I got at debugging:
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::c_str
returns: 0x003bf9d4 "TEST"
p : 0x003bf9d4 ""
It seems p is pointing to the right location but doesn't display the right content.
Why is p empty ?
std::stringreturned bytoStdString()is still exists in memory when you get tocout << p << endl;line?