[SOLVED] ToAscii() method in Qt5.2.1
In Qt5.2.1,When i want to use ToAscii() for a variable of Qstring datatype, there is no suggestion in autocomplete list!
Isn`t there this method in Qt5.2.1?
Thanks a lot.
ToAscii might have been removed. Check out the release information of Qt5.2.1: "toAscii is obsolete!!":http://qt-project.org/doc/qt-5/qstring-obsolete.html. It is an almost useless function since it's better to use the toUtf8() function.
Thanks For your response.
I want to set this question "solved". I don`t know how?
Here's what worked for me. To get a file name into an ascii string>
QString filename = "blahblahblah"; QByteArray ba = filename.toUtf8(); const char *thefile = ba.constData(); last10 = fopen(thefile,"r");
The official replacement for QString::toAscii() is QString::toLatin1(). With toUtf8() you are changing the encoding!
just like sierdzio said, it's QString::toLatin1()
To make this solved just append [SOLVED] to the title of the thread
Ah, yes, your right. toLatin1() is the correct way.
To mark as [SOLVED] there is in your first post (just below your picture) a green 'edit'. Click that and your able to change your post.