// Create a QRectF object with x=10, y=20, width=100, height=80 QRectF rect(10.0, 20.0, 100.0, 80.0); // Get the width of the rectangle qreal width = rect.width();
// Create a QRectF object with default x, y coordinates and width=50, height=50 QRectF rect(QPointF(0.0, 0.0), QSizeF(50.0, 50.0)); // Resize the rectangle to double its width and height rect.setSize(QSizeF(rect.width() * 2, rect.height() * 2));In this example, we create a QRectF object with a size of 50x50 and then change its size to 100x100 using the setSize() function. Package library: Qt Core.