[Interest] QPlainTextEdit and a Unicode file
Thiago Macieira
thiago.macieira at intel.com
Thu Apr 11 02:54:31 CEST 2013
On quarta-feira, 10 de abril de 2013 23.59.05, Scott Aron Bloom wrote:
> The Loading process is as follows:
#define QT_NO_CAST_FROM_ASCII
> QByteArray contents = fi.readAll();
> fi.close();
> setPlainText( contents );
The last line here will error out saying that you're converting from
QByteArray to QString.
Whenever you do that, you need to tell what codec to use.
If your next question is "how do I detect the encoding of a file", the answer
is that you don't. Detecting the encoding is a guessing scenario. Certain libs
have a good guess ratio, but it's still a guess.
If you must *know* the encoding, you should add the drop-down combobox to your
open dialog, or you have to add a menu to change the encoding (and reload the
file).
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130410/43236272/attachment.sig>
More information about the Interest
mailing list