Re: QGraphicsItem setpos()
What does this return?
Are you sure you're in sync with the stream? Maybe you forgot to write or read something and the contents of the stream is different than you expect?
Re: QGraphicsItem setpos()
Hi
While saving out the position, i use
Code:
out<<(qint32(textItem->pos().x()));
out<<(qint32(textItem->pos().y()));
qDebug() << (qint32(textItem->pos().x()));
qDebug() << (qint32(textItem->pos().y()));
qDebug() returns the following values:
-----------------------------------------------------
478
46
276
366
While reading in,
Code:
qint32 px;
qint32 py;
in >> px;
in >> py;
qDebug() << px;
qDebug() << py;
.....
textItem->pos().setX(px);
textItem->pos().setY(py);
qDebug() returns the following erroneous values:
1075786547
858993459
0
0
I checked the sequence, am writing out and reading in proper order.Is my syntax for setting the coordinates correct ? What am i missing ?
Thank you
Re: QGraphicsItem setpos()
I am able to read back other attributes like text,font etc.So the issue is related only to position.
Re: QGraphicsItem setpos()
Please provide a minimal compilable example reproducing the problem.
Re: QGraphicsItem setpos()
Try to save
While Writing:
Code:
p=TextItem->pos();
out<<p;
While Reading:
Code:
in>>p;
TextItem->setPos(p);
I have done like this and I got.
One more thing if there are many No. of Items Whose position is to be saved better go for and save the QList.
Re: QGraphicsItem setpos()