
Originally Posted by
nupul
Do i absolutely need to use QRect for this?
Heh, you absolutely don't have to use, I only mentioned I find QRect handy for this kind of calculations.. 

Originally Posted by
nupul
How could I do it using Qrect...could you give me an example?

// geometries
QRect areaRect
= areaWidget
->geometry
();
// the whole "area" QRect topRightRect
= topRightWidget
->geometry
();
// the "icon" in the top right corner QRect middleLeftRect
= middleLeftWidget
->geometry
();
// the "icon" in the middle left edge
// top right corner
topRightRect.moveTopRight(areaRect.topRight()); // align to top right corner
topRightWidget->setGeometry(topRightRect); // move the icon widget
// middle left edge
middleLeftRect.moveCenter(areaRect.center()); // centralize
middleLeftRect.moveLeft(areaRect.left()); // align to left edge
middleLeftWidget->setGeometry(middleLeftRect); // move the icon widget
// geometries
QRect areaRect = areaWidget->geometry(); // the whole "area"
QRect topRightRect = topRightWidget->geometry(); // the "icon" in the top right corner
QRect middleLeftRect = middleLeftWidget->geometry(); // the "icon" in the middle left edge
// top right corner
topRightRect.moveTopRight(areaRect.topRight()); // align to top right corner
topRightWidget->setGeometry(topRightRect); // move the icon widget
// middle left edge
middleLeftRect.moveCenter(areaRect.center()); // centralize
middleLeftRect.moveLeft(areaRect.left()); // align to left edge
middleLeftWidget->setGeometry(middleLeftRect); // move the icon widget
To copy to clipboard, switch view to plain text mode
As you can see, with QRect it's simple to align items to corners/edges.
Bookmarks