Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Big problem in reading&writing binary files
i have a big problem in qt, assume that i use binary files and write data to them.
my data are strings,
and i want them string (in output mode) whenever i read them.
any help will be appreciated :)
thanks in advance.
Jeroentjehome last edited by
On your QFile pointer you could set a QByteArray and check out that class to define how do you need that data from the file. The fromHex en toHex jump to mind in your case.
Thanks for your reply,
look, this is my code :
QString strToWrite = ui->User_signUp->text()+ui->Pass_signUp->text();
dataStreamWriter << strToWrite;
and for reading:
QString strToRead= "";
dataStreamReader >> strToRead;
qDebug() << strToRead;
but in this case problem is that qDebug does'nt work.
Hi and welcome to devnet,
Is it a typo or are you really writing to users.bin and reading from file.bin ?
Sorry i change the code with QByteArray,
QByteArray ar=ui->User_signUp->text().toUtf8()+"%"+ ui->Pass_singUp->text().toUtf8()+"$";
file.open(QIODevice::WriteOnly | QIODevice::Append );
this code writes the usernames and passwords correctly
Now assume that i want to search a specified String(username) in my file, I think i can do this by using 2 QByteArrays, one for the username (which user has entered) and another for the file which reads whole file.
but i don't know how i can use them. could you help me?
Are you thinking about QByteArray::contains ?