QRect rect(0, 0, 100, 100); int x = rect.topRight().x(); // x will be 100
QWidget* parentWidget = new QWidget; QWidget* childWidget = new QWidget(parentWidget); childWidget->move(parentWidget->rect().topRight() - childWidget->rect().topRight());
void MyWidget::paintEvent(QPaintEvent* event) { QPainter painter(this); QPoint center = rect.center(); QPoint topRight = rect.topRight(); painter.drawLine(center, topRight); }The package library for QRect and topRight is the Qt library, specifically the QtGui module.