CPP. Convert QString to Base64 encoded QString

This CPP snippet shows how to convert a QString to Base64 encoded QString.

QString base64_encode(QString string){
    QByteArray ba;
    ba.append(string);
    return ba.toBase64();
}