Hi Friends,
I am working to creat an application where I need to have a scene where i am going to place QGraphicsItems on that scene dynamically then I need to save that scene and retrive that scene as a QGraphicsScene only wher user can modify the graphics Item again and save.
now my code for saving is
QFile file("fileName.dat");
if(scene->items().isEmpty()) //scene is QGraphicsScene variable
return 0;
else
QList<QGraphicsItem *>itemsList=scene->items();
out<<itemsList;
QFile file("fileName.dat");
file.open(QIODevice::WriteOnly);
QDataStream out(&file);
if(scene->items().isEmpty()) //scene is QGraphicsScene variable
return 0;
else
QList<QGraphicsItem *>itemsList=scene->items();
out<<itemsList;
To copy to clipboard, switch view to plain text mode
My code for opening the saved file is
{
return 0;
}
else
{
QList<QGraphicsItem *>itemsList=scene->items();
in>>itemsList;
scene->addItem(item);
file.close();
QString fileName=QFileDialog::getOpenFileName(this,tr("Open File"),QDir::currentPath()):
QFile file(fileName);
if(file.open(QIODevice::ReadOnly))
{
QMessageBox::information(this,tr("Unable to open");
return 0;
}
else
{
QList<QGraphicsItem *>itemsList=scene->items();
QDataStream in(&file);
in>>itemsList;
foreach(QGraphicsItem *item,itemList)
scene->addItem(item);
file.close();
To copy to clipboard, switch view to plain text mode
Thats all logically I think I am Correct but I am Getting an error
"no match for 'operator>>' in 's>>t' in qdatastream.h
Plz help me friends where i am going wrong or is there any other method for my requirement.
with Regards,
srikanth
Bookmarks