[SOLVED] ToAscii() method in Qt5.2.1
-
wrote on 28 Feb 2014, 07:41 last edited by
Hello dears.
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.
Ya Ali. -
wrote on 28 Feb 2014, 08:07 last edited by
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.
-
wrote on 28 Feb 2014, 14:25 last edited by
Thanks For your response.
I want to set this question "solved". I don`t know how? -
wrote on 1 Mar 2014, 15:16 last edited by
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!
-
wrote on 3 Mar 2014, 08:58 last edited by
just like sierdzio said, it's QString::toLatin1()
To make this solved just append [SOLVED] to the title of the thread -
wrote on 3 Mar 2014, 09:11 last edited by
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.
1/7