OK. To understand this, I was trying to save QVector<int> object.
So I created two function to save and load:
void MainWindow::save()
{
return;
else
{
out << asd[0];
qDebug()<<"ok";
plik.close();
}
}
void MainWindow::save()
{
QFile file("path....");
if(!plik.open(QIODevice::ReadWrite))
return;
else
{
QDataStream out(&file);
QDataStream & operator<<(QDataStream & out, const QVector<int> & asd);
out << asd[0];
qDebug()<<"ok";
plik.close();
}
}
To copy to clipboard, switch view to plain text mode
void MainWindow::load()
{
return;
else
{
asd.insert(0,1);
in >> asd [0];
qDebug()<<"ok!";
}
}
void MainWindow::load()
{
QFile plik("path....");
if(!plik.open(QIODevice::ReadWrite))
return;
else
{
QDataStream in(&file);
QDataStream & operator>>(QDataStream & in, QVector<int> & asd);
asd.insert(0,1);
in >> asd [0];
qDebug()<<"ok!";
}
}
To copy to clipboard, switch view to plain text mode
and this working great (now for only one item in array).
But now I have two question about that:
1. Can't I save all of asd objects (without loop of asd[x])?
2. What I can save object of QVector<myOwnClass>?
I tried:
out << pyt[0];
QDataStream out(&plik);
QDataStream & operator<<(QDataStream & out, const QVector<pytania> & pyt);
out << pyt[0];
To copy to clipboard, switch view to plain text mode
but this doesn't works..
Bookmarks