blooglet
10th February 2011, 13:34
I'm trying to update the width and height of a QGraphicsItem. I've added QGraphicsItem* testItem to a graphics scene using the addItem function.
The documentation says I can use the update function to change the width and height, but the item doesn't change.
int newWidth = /* something */;
int newHeight = /* something */;
QRectF newRect = QRectF(testItem->x(), testItem->y(), newWidth, newHeight);
testItem->update(newRect);
QMessageBox msg1;
msg1.setText("Update successful? " + QString((testItem->boundingRect().width() == width) ? "true" : "false") + QString("\n\nRequested size: ") + QString::number(newWidth) + " x " + QString::number(newHeight) + "\nActual size: " + QString::number(testItem->boundingRect().width()) + " x " + QString::number(testItem->boundingRect().height()));
msg1.exec();
http://i.imgur.com/Oo9BA.png
Why isn't it updating correctly?
The documentation says I can use the update function to change the width and height, but the item doesn't change.
int newWidth = /* something */;
int newHeight = /* something */;
QRectF newRect = QRectF(testItem->x(), testItem->y(), newWidth, newHeight);
testItem->update(newRect);
QMessageBox msg1;
msg1.setText("Update successful? " + QString((testItem->boundingRect().width() == width) ? "true" : "false") + QString("\n\nRequested size: ") + QString::number(newWidth) + " x " + QString::number(newHeight) + "\nActual size: " + QString::number(testItem->boundingRect().width()) + " x " + QString::number(testItem->boundingRect().height()));
msg1.exec();
http://i.imgur.com/Oo9BA.png
Why isn't it updating correctly?