How to Convert Unreadable Binary to Readable QString

Posted on Posted in Qt Tutorials, Tutorials

Web developers are quite familiar with Base64 and its usage. To put it simply, whenever to want to store, transfer (send or receive) or do anything else with the contents of a binary file (in this example, an image file) you can use Base64 encoding to simplify things by converting unreadable binary contents to a readable string.

A very common usage would be to send an image to a web server somewhere. Or you can use this to transmit complex binary contents over TCP/IP or Serial communication.

The example project here shows how easy it is to convert any binary file to QString in Qt.

It simply uses QByteArray::toBase64 method to convert QByteArray to QString and displays it in a text editor. You can build and use it as a File to Base64 converter.

You can find the downloadable example project below:



Leave a Reply

Your email address will not be published. Required fields are marked *