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.

Qt Code:
  1. int newWidth = /* something */;
  2. int newHeight = /* something */;
  3. QRectF newRect = QRectF(testItem->x(), testItem->y(), newWidth, newHeight);
  4. testItem->update(newRect);
  5.  
  6. 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()));
  7. msg1.exec();
To copy to clipboard, switch view to plain text mode 



Why isn't it updating correctly?