A
alessio211734
I have problem with conversion from QString to const char * , I know that it's not the right newsgroup but I don't know if is a c++ issue problem.
void _file(const char * file)
{
std::string fileString(file);
int a=0;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QString str("ciao");
const char * xxx=str.toLatin1().constData();
_file(str.toLatin1().constData());
_file(xxx);
MainWindow w;
w.show();
return a.exec();
}
at the first call "_file(str.toLatin1().constData())" the debugger show that the parameter passed to function _file have the correct value while in the last call _file(xxx) the parameters passed to _file function is incorrect. I didn't understand why?
void _file(const char * file)
{
std::string fileString(file);
int a=0;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QString str("ciao");
const char * xxx=str.toLatin1().constData();
_file(str.toLatin1().constData());
_file(xxx);
MainWindow w;
w.show();
return a.exec();
}
at the first call "_file(str.toLatin1().constData())" the debugger show that the parameter passed to function _file have the correct value while in the last call _file(xxx) the parameters passed to _file function is incorrect. I didn't understand why?