summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-05-14 22:02:58 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-05-14 22:02:58 (GMT)
commite3fcf351dee44b4f9457a6abbed76d37fc0fbe67 (patch)
tree2c5e0a4eaedbfa1aa8145b6aef6bdd93a38f92fb /doc
parentf36d2e5cd0655cee2a1bfb84a66400a4b7a4c454 (diff)
parentae3f20e9ce7f592c22c23e8dea6bb9feb52c8b90 (diff)
downloadQt-e3fcf351dee44b4f9457a6abbed76d37fc0fbe67.zip
Qt-e3fcf351dee44b4f9457a6abbed76d37fc0fbe67.tar.gz
Qt-e3fcf351dee44b4f9457a6abbed76d37fc0fbe67.tar.bz2
Merge branch '4.5'
Conflicts: tools/macdeployqt/shared/shared.cpp
Diffstat (limited to 'doc')
-rw-r--r--doc/src/layout.qdoc16
-rw-r--r--doc/src/snippets/code/doc_src_layout.qdoc41
2 files changed, 33 insertions, 24 deletions
diff --git a/doc/src/layout.qdoc b/doc/src/layout.qdoc
index 55dfd8b..196999b 100644
--- a/doc/src/layout.qdoc
+++ b/doc/src/layout.qdoc
@@ -315,7 +315,11 @@
\snippet doc/src/snippets/code/doc_src_layout.qdoc 1
- First we define two functions that iterate over the layout: \c{itemAt()}
+ First we define \c{count()} to fetch the number of items in the list.
+
+ \snippet doc/src/snippets/code/doc_src_layout.qdoc 2
+
+ Then we define two functions that iterate over the layout: \c{itemAt()}
and \c{takeAt()}. These functions are used internally by the layout system
to handle deletion of widgets. They are also available for application
programmers.
@@ -326,7 +330,7 @@
structure, we may have to spend more effort defining a linear order for the
items.
- \snippet doc/src/snippets/code/doc_src_layout.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_layout.qdoc 3
\c{addItem()} implements the default placement strategy for layout items.
This function must be implemented. It is used by QLayout::add(), by the
@@ -336,26 +340,26 @@
QGridLayout::addItem(), QGridLayout::addWidget(), and
QGridLayout::addLayout().
- \snippet doc/src/snippets/code/doc_src_layout.qdoc 3
+ \snippet doc/src/snippets/code/doc_src_layout.qdoc 4
The layout takes over responsibility of the items added. Since QLayoutItem
does not inherit QObject, we must delete the items manually. The function
QLayout::deleteAllItems() uses \c{takeAt()} defined above to delete all the
items in the layout.
- \snippet doc/src/snippets/code/doc_src_layout.qdoc 4
+ \snippet doc/src/snippets/code/doc_src_layout.qdoc 5
The \c{setGeometry()} function actually performs the layout. The rectangle
supplied as an argument does not include \c{margin()}. If relevant, use
\c{spacing()} as the distance between items.
- \snippet doc/src/snippets/code/doc_src_layout.qdoc 5
+ \snippet doc/src/snippets/code/doc_src_layout.qdoc 6
\c{sizeHint()} and \c{minimumSize()} are normally very similar in
implementation. The sizes returned by both functions should include
\c{spacing()}, but not \c{margin()}.
- \snippet doc/src/snippets/code/doc_src_layout.qdoc 6
+ \snippet doc/src/snippets/code/doc_src_layout.qdoc 7
\section2 Further Notes
diff --git a/doc/src/snippets/code/doc_src_layout.qdoc b/doc/src/snippets/code/doc_src_layout.qdoc
index 48e10e9..fedcf0c 100644
--- a/doc/src/snippets/code/doc_src_layout.qdoc
+++ b/doc/src/snippets/code/doc_src_layout.qdoc
@@ -2,23 +2,21 @@
#ifndef CARD_H
#define CARD_H
-#include <QLayout>
+#include <QtGui>
#include <QList>
class CardLayout : public QLayout
{
public:
- CardLayout(QWidget *parent, int dist)
- : QLayout(parent, 0, dist) {}
- CardLayout(QLayout *parent, int dist)
- : QLayout(parent, dist) {}
- CardLayout(int dist)
- : QLayout(dist) {}
+ CardLayout(QWidget *parent, int dist): QLayout(parent, 0, dist) {}
+ CardLayout(QLayout *parent, int dist): QLayout(parent, dist) {}
+ CardLayout(int dist): QLayout(dist) {}
~CardLayout();
void addItem(QLayoutItem *item);
QSize sizeHint() const;
QSize minimumSize() const;
+ QLayoutItem *count() const;
QLayoutItem *itemAt(int) const;
QLayoutItem *takeAt(int);
void setGeometry(const QRect &rect);
@@ -31,11 +29,18 @@ private:
//! [1]
-#include "card.h"
+//#include "card.h"
//! [1]
-
//! [2]
+QLayoutItem *CardLayout::count() const
+{
+ // QList::size() returns the number of QLayoutItems in the list
+ return list.size();
+}
+//! [2]
+
+//! [3]
QLayoutItem *CardLayout::itemAt(int idx) const
{
// QList::value() performs index checking, and returns 0 if we are
@@ -48,26 +53,26 @@ QLayoutItem *CardLayout::takeAt(int idx)
// QList::take does not do index checking
return idx >= 0 && idx < list.size() ? list.takeAt(idx) : 0;
}
-//! [2]
+//! [3]
-//! [3]
+//! [4]
void CardLayout::addItem(QLayoutItem *item)
{
list.append(item);
}
-//! [3]
+//! [4]
-//! [4]
+//! [5]
CardLayout::~CardLayout()
{
deleteAllItems();
}
-//! [4]
+//! [5]
-//! [5]
+//! [6]
void CardLayout::setGeometry(const QRect &r)
{
QLayout::setGeometry(r);
@@ -85,10 +90,10 @@ void CardLayout::setGeometry(const QRect &r)
++i;
}
}
-//! [5]
+//! [6]
-//! [6]
+//! [7]
QSize CardLayout::sizeHint() const
{
QSize s(0,0);
@@ -116,4 +121,4 @@ QSize CardLayout::minimumSize() const
}
return s + n*QSize(spacing(), spacing());
}
-//! [6]
+//! [7] \ No newline at end of file