QRect rect(0, 0, 100, 50); rect.setWidth(200);
QRect rect = someWidget->geometry(); QSize size = someOtherWidget->size(); rect.setWidth(size.width());In this example, we get the geometry of a widget and store it in a QRect object called “rect”. Then we get the size of another widget and store it in a QSize object called “size”. Finally, we call the setWidth method to set the width of “rect” to the width of “size”. Package/library: Qt Framework (QtCore module)