Hi,
Because of needing for saving some double, int and QStringList variables, my project works with 3 files that have written and read binary. these 3 files are for reading from them and setting some values from them and if there are some changing, I save (write) the changes in these files. I compiled my project statically and all of output is a standalone ".exe" and these 3 files beside of this ".exe".
I want to put these 3 files inside the ".exe" but because of writing into them I can not put them into the resources folder.
one idea is: writing all of my data (double, int and QStringList variables) only into the 1 file. please help me in this way how could I.
and in the other hand, is it possible to put these 3 files into ".exe" of my project?
my code:
QFile g1f, g2f, of, namef
// writing my 3 files g1f.setFileName("ga.bin");
if(!g1f.
open(QFile::WriteOnly)) {
qDebug()<<"can not open to write";
}
g1f.write((char*)g1, 500*sizeof(double));//1-writing binary my double variables into a file in name of "ga.bin"
g1f.flush();
g1f.close();
g2f.setFileName("g.bin");
if(!g2f.
open(QFile::WriteOnly)) {
qDebug()<<"can not open to write";
}
g2f.write((char*)g2, 500**sizeof(int));//2-writing binary my int variables into an another file in name of "g.bin"
g2f.flush();
g2f.close();
namef.setFileName("n.bin");//3--writing binary my QString variables into an another file in name of "n.bin"
if(!namef.
open(QFile::WriteOnly)) {
qDebug()<<"can not open to write";
}
df << names;//names is an object of QStringList
namef.flush();
namef.close();
QFile g1f, g2f, of, namef // writing my 3 files
g1f.setFileName("ga.bin");
if(!g1f.open(QFile::WriteOnly))
{
qDebug()<<"can not open to write";
}
g1f.write((char*)g1, 500*sizeof(double));//1-writing binary my double variables into a file in name of "ga.bin"
g1f.flush();
g1f.close();
g2f.setFileName("g.bin");
if(!g2f.open(QFile::WriteOnly))
{
qDebug()<<"can not open to write";
}
g2f.write((char*)g2, 500**sizeof(int));//2-writing binary my int variables into an another file in name of "g.bin"
g2f.flush();
g2f.close();
namef.setFileName("n.bin");//3--writing binary my QString variables into an another file in name of "n.bin"
if(!namef.open(QFile::WriteOnly))
{
qDebug()<<"can not open to write";
}
QDataStream df(&namef);
df << names;//names is an object of QStringList
namef.flush();
namef.close();
To copy to clipboard, switch view to plain text mode
QFile g1f1, g2f1, of1, namef1
//reading 3 files that has been written above
g1f1.setFileName("ga.bin");//1-reading binary the double variables
if(!g1f1.
open(QFile::ReadOnly)) {
qDebug()<<"can not open to read";
}
g1f1.read((char*)g1, 500**sizeof(double));
g1f1.close();
g2f1.setFileName("g.bin");
if(!g2f1.
open(QFile::ReadOnly)) {
qDebug()<<"can not open to read";
}
g2f1.read((char*)g2, 500*sizeof(int));//2-reading binary the int variables
g2f1.close();
of1.setFileName("o.bin");
if(!of1.
open(QFile::ReadOnly)) {
qDebug()<<"can not open to read";
}
of1.read((char*)ofse, 500*sizeof(double));
of1.close();
namef1.setFileName("n.bin");//3-reading binary the QString variables
if(!namef1.
open(QFile::ReadOnly)) {
qDebug()<<"can not open to read";
}
fg >> names1;//names1 is an object of QStringList
close();
QFile g1f1, g2f1, of1, namef1 //reading 3 files that has been written above
g1f1.setFileName("ga.bin");//1-reading binary the double variables
if(!g1f1.open(QFile::ReadOnly))
{
qDebug()<<"can not open to read";
}
g1f1.read((char*)g1, 500**sizeof(double));
g1f1.close();
g2f1.setFileName("g.bin");
if(!g2f1.open(QFile::ReadOnly))
{
qDebug()<<"can not open to read";
}
g2f1.read((char*)g2, 500*sizeof(int));//2-reading binary the int variables
g2f1.close();
of1.setFileName("o.bin");
if(!of1.open(QFile::ReadOnly))
{
qDebug()<<"can not open to read";
}
of1.read((char*)ofse, 500*sizeof(double));
of1.close();
namef1.setFileName("n.bin");//3-reading binary the QString variables
if(!namef1.open(QFile::ReadOnly))
{
qDebug()<<"can not open to read";
}
QDataStream fg(&namef1);
fg >> names1;//names1 is an object of QStringList
close();
To copy to clipboard, switch view to plain text mode
first, can i put these 3 files (that i am reading from them and writing into them), into the ".exe" file and not beside of it? if not, then how can i have only one file instead of 3 files?
thanks for any help
Bookmarks