summaryrefslogtreecommitdiffstats
path: root/examples/graphicsview
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-09-11 10:34:08 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-09-14 12:22:01 (GMT)
commit89620720e9969360254f950fc63d131d82dd3471 (patch)
tree1117641c58ac7810549647e01ac26d5ab4845029 /examples/graphicsview
parent41dbc4406791f82b7e3c1385acc594e22b5b0799 (diff)
downloadQt-89620720e9969360254f950fc63d131d82dd3471.zip
Qt-89620720e9969360254f950fc63d131d82dd3471.tar.gz
Qt-89620720e9969360254f950fc63d131d82dd3471.tar.bz2
API change. This will get rid of the ugly setAnchorSpacing() method.
Say hello to QGraphicsAnchor, move the spacing (and removeAnchor) functionality over to that class. This also opens up for a cleaner API when we add support for size policies or min/pref/max sizes for anchors. Also remove - addLeftAndRightAnchors() - addTopAndBottomAnchors() - addAllAnchors() in favor of - addAnchors(itemA, itemB, Qt::Orientations) API change discussed with Caio and Andreas. Reviewed-by: Alexis
Diffstat (limited to 'examples/graphicsview')
-rw-r--r--examples/graphicsview/anchorlayout/main.cpp83
1 files changed, 31 insertions, 52 deletions
diff --git a/examples/graphicsview/anchorlayout/main.cpp b/examples/graphicsview/anchorlayout/main.cpp
index 4269eaa..a4bf1d0 100644
--- a/examples/graphicsview/anchorlayout/main.cpp
+++ b/examples/graphicsview/anchorlayout/main.cpp
@@ -79,66 +79,45 @@ int main(int argc, char **argv)
QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G");
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ l->setSpacing(0);
QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window);
w->setPos(20, 20);
w->setLayout(l);
// vertical
- l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop);
- l->setAnchorSpacing(a, Qt::AnchorTop, l, Qt::AnchorTop, 0);
- l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop);
- l->setAnchorSpacing(b, Qt::AnchorTop, l, Qt::AnchorTop, 0);
-
- l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorTop, a, Qt::AnchorBottom, 0);
- l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorTop, b, Qt::AnchorBottom, 0);
- l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0);
- l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorBottom, e, Qt::AnchorTop, 0);
-
- l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
- l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->setAnchorSpacing(e, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
-
- l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop);
- l->setAnchorSpacing(c, Qt::AnchorTop, f, Qt::AnchorTop, 0);
- l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom, 0);
- l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop);
- l->setAnchorSpacing(f, Qt::AnchorBottom, g, Qt::AnchorTop, 0);
- l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom);
- l->setAnchorSpacing(c, Qt::AnchorBottom, g, Qt::AnchorBottom, 0);
+ QGraphicsAnchor *anchor = l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop);
+ anchor = l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop);
+
+ anchor = l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom);
+ anchor = l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom);
+ anchor = l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
+ anchor = l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop);
+
+ anchor = l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom);
+ anchor = l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom);
+
+ anchor = l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop);
+ anchor = l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom);
+ anchor = l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop);
+ anchor = l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom);
// horizontal
- l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
- l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, d, Qt::AnchorLeft, 0);
- l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0);
-
- l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft);
- l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0);
- l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft);
- l->setAnchorSpacing(c, Qt::AnchorRight, e, Qt::AnchorLeft, 0);
-
- l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(b, Qt::AnchorRight, l, Qt::AnchorRight, 0);
- l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight);
- l->setAnchorSpacing(e, Qt::AnchorRight, l, Qt::AnchorRight, 0);
- l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft);
- l->setAnchorSpacing(d, Qt::AnchorRight, e, Qt::AnchorLeft, 0);
-
- l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, f, Qt::AnchorLeft, 0);
- l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft);
- l->setAnchorSpacing(l, Qt::AnchorLeft, g, Qt::AnchorLeft, 0);
- l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight);
- l->setAnchorSpacing(f, Qt::AnchorRight, g, Qt::AnchorRight, 0);
+ anchor = l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
+ anchor = l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft);
+ anchor = l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
+
+ anchor = l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft);
+ anchor = l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft);
+
+ anchor = l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight);
+ anchor = l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight);
+ anchor = l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft);
+
+ anchor = l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft);
+ anchor = l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft);
+ anchor = l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight);
+
scene.addItem(w);
scene.setBackgroundBrush(Qt::darkGreen);