QPoint RubberBand::getTopLeft() const { int width = (mMouseNow.x() - mPosition.x()); int height = (mMouseNow.y() - mPosition.y()); QRect newGeom(mPosition.x(), mPosition.y(), width, height); return newGeom.normalized().topLeft(); }
void RubberBand::updatePath() { //we have to reset the path to remove the old rectangle resetPath(); int width = (mMouseNow.x() - mPosition.x()); int height = (mMouseNow.y() - mPosition.y()); QRect newGeom(mPosition.x(), mPosition.y(), width, height); newGeom = newGeom.normalized(); setGeometry(newGeom); mPath.addRect(0.5, 0.5, newGeom.width()-1, newGeom.height()-1); }
void tst_QBoxLayout::setGeometry() { QWidget w; QVBoxLayout *lay = new QVBoxLayout; lay->setMargin(0); lay->setSpacing(0); QHBoxLayout *lay2 = new QHBoxLayout; QDial *dial = new QDial; lay2->addWidget(dial); lay2->setAlignment(Qt::AlignTop); lay2->setAlignment(Qt::AlignRight); lay->addLayout(lay2); w.setLayout(lay); w.show(); QRect newGeom(0, 0, 70, 70); lay2->setGeometry(newGeom); QVERIFY2(newGeom.contains(dial->geometry()), "dial->geometry() should be smaller and within newGeom"); }