summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsanchorlayout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/graphicsview/qgraphicsanchorlayout.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.cpp49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
index 3c2ea37..95561b7 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
+** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -34,7 +34,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
+** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -65,8 +65,9 @@
automatically added to the layout, and if items are removed, all their anchors will be
automatically removed
- \section1 Size Hints and Size Policies in QGraphicsLinearLayout
- QGraphicsLinearLayout respects each item's size hints and size policies. However it does
+ \section1 Size Hints and Size Policies in QGraphicsAnchorLayout
+
+ QGraphicsAnchorLayout respects each item's size hints and size policies. However it does
not respect stretch factors currently. This might change in the future, so please refrain
from using stretch factors in anchor layout to avoid any future regressions.
@@ -83,6 +84,10 @@
QT_BEGIN_NAMESPACE
+/*!
+ Constructs a QGraphicsAnchorLayout instance. \a parent is passed to
+ QGraphicsLayout's constructor.
+ */
QGraphicsAnchorLayout::QGraphicsAnchorLayout(QGraphicsLayoutItem *parent)
: QGraphicsLayout(*new QGraphicsAnchorLayoutPrivate(), parent)
{
@@ -90,6 +95,9 @@ QGraphicsAnchorLayout::QGraphicsAnchorLayout(QGraphicsLayoutItem *parent)
d->createLayoutEdges();
}
+/*!
+ Destroys the QGraphicsAnchorLayout object.
+*/
QGraphicsAnchorLayout::~QGraphicsAnchorLayout()
{
Q_D(QGraphicsAnchorLayout);
@@ -187,32 +195,41 @@ void QGraphicsAnchorLayout::addCornerAnchors(QGraphicsLayoutItem *firstItem,
}
/*!
- \fn QGraphicsAnchorLayout::addLeftAndRightAnchors(QGraphicsLayoutItem *firstEdge, QGraphicsLayoutItem *secondEdge)
+ \fn QGraphicsAnchorLayout::addLeftAndRightAnchors(QGraphicsLayoutItem *firstItem, QGraphicsLayoutItem *secondItem)
+
+ Anchors the left and right edges of \a firstItem to the same edges of
+ \a secondItem.
This convenience function is equivalent to calling
\code
- l->addAnchor(firstEdge, Qt::AnchorLeft, secondEdge, Qt::AnchorLeft);
- l->addAnchor(firstEdge, Qt::AnchorRight, secondEdge, Qt::AnchorRight);
+ l->addAnchor(firstItem, Qt::AnchorLeft, secondItem, Qt::AnchorLeft);
+ l->addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
\endcode
*/
/*!
- \fn QGraphicsAnchorLayout::addTopAndBottomAnchors(QGraphicsLayoutItem *firstEdge, QGraphicsLayoutItem *secondEdge)
+ \fn QGraphicsAnchorLayout::addTopAndBottomAnchors(QGraphicsLayoutItem *firstItem, QGraphicsLayoutItem *secondItem)
+
+ Anchors the top and bottom edges of \a firstItem to the same edges of
+ \a secondItem.
This convenience function is equivalent to calling
\code
- l->addAnchor(firstEdge, Qt::AnchorTop, secondEdge, Qt::AnchorTop);
- l->addAnchor(firstEdge, Qt::AnchorBottom, secondEdge, Qt::AnchorBottom);
+ l->addAnchor(firstItem, Qt::AnchorTop, secondItem, Qt::AnchorTop);
+ l->addAnchor(firstItem, Qt::AnchorBottom, secondItem, Qt::AnchorBottom);
\endcode
*/
/*!
- \fn QGraphicsAnchorLayout::addAllAnchors(QGraphicsLayoutItem *firstEdge, QGraphicsLayoutItem *secondEdge)
+ \fn QGraphicsAnchorLayout::addAllAnchors(QGraphicsLayoutItem *firstItem, QGraphicsLayoutItem *secondItem)
+
+ Anchors all edges (left, right, top and bottom) of \a firstItem to the same edges of
+ \a secondItem.
This convenience function is equivalent to calling
\code
- l->addLeftAndRightAnchors(firstEdge, secondEdge);
- l->addTopAndBottomAnchors(firstEdge, secondEdge);
+ l->addLeftAndRightAnchors(firstItem, secondItem);
+ l->addTopAndBottomAnchors(firstItem, secondItem);
\endcode
*/
@@ -228,6 +245,7 @@ void QGraphicsAnchorLayout::setAnchorSpacing(const QGraphicsLayoutItem *firstIte
if (!d->setAnchorSize(firstItem, firstEdge, secondItem, secondEdge, &spacing)) {
qWarning("setAnchorSpacing: The anchor does not exist.");
+ return;
}
invalidate();
}
@@ -369,7 +387,12 @@ void QGraphicsAnchorLayout::setGeometry(const QRectF &geom)
}
/*!
+ Removes the layout item at \a index without destroying it. Ownership of
+ the item is transferred to the caller.
+
Removing an item will also remove any of the anchors associated with it.
+
+ \sa itemAt(), count()
*/
void QGraphicsAnchorLayout::removeAt(int index)
{