Unsolved Converting QString to Base64
-
Hello,
I am currently facing the problem that I am not able convert a QString to a base64 code. This is my current try:QString filepath = "C:\example.txt";
QFile file(filepath);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QString line;
QTextStream in(&file);while(!in.atEnd()){ line.append(in.readLine()); } QString base64 = line; base64.toUtf8().toBase64(); qDebug()<<base64;
The Output is not a base64 code
-
Hi,
What input do you have ?
What output do you expect ?
What output do you get ? -
@Chaki said in Converting QString to Base64:
base64.toUtf8().toBase64();
C++ basics - what do you expect from this line?
-
@Chaki
When you read https://doc.qt.io/qt-5/qbytearray.html#toBase64 you see:QByteArray QByteArray::toBase64() const
`Returns a copy of the byte array, encoded as Base64.So it is a function returning a result.
-
@Christian-Ehrlicher i thought this line converts a QString to a base64 code
-
@Chaki said in Converting QString to Base64:
i thought this line converts a QString to a base64 code
Correct, but the result is thrown away since you don't save the return value - c basics.
-
@Christian-Ehrlicher
Yes you're right sir
Thanks a lot! -
@Chaki is your issue solved then? if so please don't forget to mark your post as such!