I found in google that this is not good.
So I try this
bool MainScene
::loadFile(const QString &fileName
) {
return false;
quint32 magicWord, second;
inStream >> magicWord >> second;
if (magicWord != 0xA0B0C0D0) return false;
inStream >> list;
file.close();
return true;
}
bool MainScene
::saveFile(const QString &fileName
) {
return false;
outStream << (quint32)0xA0B0C0D0;
outStream << (qint32)123;
outStream << list;
file.close();
return true;
}
{
out << qint16(item->itemType()) << item->sceneBoundingRect() << item->pen() << item->brush() << item->pos() << item->zValue();
return out;
}
{
qint16 type;
int zValue;
in >> type >> rect >> pen >> brush >> point >> zValue;
item = new Item((Item::ItemType)type, rect);
item->setPen(pen);
item->setBrush(brush);
item->setPos(point);
item->setZValue(zValue);
return in;
}
bool MainScene::loadFile(const QString &fileName)
{
QFile file(fileName);
if(!file.open(QIODevice::ReadOnly))
return false;
QDataStream inStream(&file);
inStream.setVersion(QDataStream::Qt_4_4);
quint32 magicWord, second;
inStream >> magicWord >> second;
if (magicWord != 0xA0B0C0D0) return false;
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); // set wait cursor during loading
inStream >> list;
QApplication::restoreOverrideCursor();
file.close();
return true;
}
bool MainScene::saveFile(const QString &fileName)
{
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly))
return false;
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); // set wait cursor during saving
QDataStream outStream(&file);
outStream.setVersion(QDataStream::Qt_4_4);
outStream << (quint32)0xA0B0C0D0;
outStream << (qint32)123;
outStream << list;
QApplication::restoreOverrideCursor();
file.close();
return true;
}
QDataStream &operator<<(QDataStream &out, const Item *item)
{
out << qint16(item->itemType()) << item->sceneBoundingRect() << item->pen() << item->brush() << item->pos() << item->zValue();
return out;
}
QDataStream &operator>>(QDataStream &in, Item *item)
{
qint16 type;
QRectF rect;
QPen pen;
QBrush brush;
QPointF point;
int zValue;
in >> type >> rect >> pen >> brush >> point >> zValue;
item = new Item((Item::ItemType)type, rect);
item->setPen(pen);
item->setBrush(brush);
item->setPos(point);
item->setZValue(zValue);
return in;
}
To copy to clipboard, switch view to plain text mode
But programm crash when I try to load my file 
What is wrong? Or I cannot send to QDataStream all QRect or QPen or QBrush, etc?
edit: or I have to "convert" all QRect or QPen or QBrush, etc... to uint which is described in THIS? It could be hard, isnt it?
Bookmarks