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);
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();
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();
To copy to clipboard, switch view to plain text mode

Why isn't it updating correctly?
Bookmarks