summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-04-29 17:51:02 (GMT)
committerBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-04-29 17:51:02 (GMT)
commitd355e069ca1952504ef8cc6fb44350b53314d5d5 (patch)
treef2372d54b1bf988312ff4ab0b91b7d3e74629367 /examples
parentd20bf7c8b368cb56df1a965793edbd23ff0c3213 (diff)
parent073b7ce298b0e079f310ec22dee44a9fc0af9ee6 (diff)
downloadQt-d355e069ca1952504ef8cc6fb44350b53314d5d5.zip
Qt-d355e069ca1952504ef8cc6fb44350b53314d5d5.tar.gz
Qt-d355e069ca1952504ef8cc6fb44350b53314d5d5.tar.bz2
Merge commit 'origin/4.5'
Diffstat (limited to 'examples')
-rw-r--r--examples/layouts/flowlayout/flowlayout.cpp27
-rw-r--r--examples/layouts/flowlayout/flowlayout.h3
-rw-r--r--examples/layouts/flowlayout/window.cpp3
-rw-r--r--examples/layouts/flowlayout/window.h3
4 files changed, 30 insertions, 6 deletions
diff --git a/examples/layouts/flowlayout/flowlayout.cpp b/examples/layouts/flowlayout/flowlayout.cpp
index c4032d0..263911d 100644
--- a/examples/layouts/flowlayout/flowlayout.cpp
+++ b/examples/layouts/flowlayout/flowlayout.cpp
@@ -42,7 +42,7 @@
#include <QtGui>
#include "flowlayout.h"
-
+//! [1]
FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
{
@@ -54,19 +54,25 @@ FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}
+//! [1]
+//! [2]
FlowLayout::~FlowLayout()
{
QLayoutItem *item;
while ((item = takeAt(0)))
delete item;
}
+//! [2]
+//! [3]
void FlowLayout::addItem(QLayoutItem *item)
{
itemList.append(item);
}
+//! [3]
+//! [4]
int FlowLayout::horizontalSpacing() const
{
if (m_hSpace >= 0) {
@@ -84,7 +90,9 @@ int FlowLayout::verticalSpacing() const
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
}
}
+//! [4]
+//! [5]
int FlowLayout::count() const
{
return itemList.size();
@@ -102,12 +110,16 @@ QLayoutItem *FlowLayout::takeAt(int index)
else
return 0;
}
+//! [5]
+//! [6]
Qt::Orientations FlowLayout::expandingDirections() const
{
return 0;
}
+//! [6]
+//! [7]
bool FlowLayout::hasHeightForWidth() const
{
return true;
@@ -118,7 +130,9 @@ int FlowLayout::heightForWidth(int width) const
int height = doLayout(QRect(0, 0, width, 0), true);
return height;
}
+//! [7]
+//! [8]
void FlowLayout::setGeometry(const QRect &rect)
{
QLayout::setGeometry(rect);
@@ -140,7 +154,9 @@ QSize FlowLayout::minimumSize() const
size += QSize(2*margin(), 2*margin());
return size;
}
+//! [8]
+//! [9]
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
{
int left, top, right, bottom;
@@ -149,7 +165,9 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
int x = effectiveRect.x();
int y = effectiveRect.y();
int lineHeight = 0;
+//! [9]
+//! [10]
QLayoutItem *item;
foreach (item, itemList) {
QWidget *wid = item->widget();
@@ -161,6 +179,8 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
if (spaceY == -1)
spaceY = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
+//! [10]
+//! [11]
int nextX = x + item->sizeHint().width() + spaceX;
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
x = effectiveRect.x();
@@ -177,7 +197,8 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
}
return y + lineHeight - rect.y() + bottom;
}
-
+//! [11]
+//! [12]
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
{
QObject *parent = this->parent();
@@ -190,4 +211,4 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
return static_cast<QLayout *>(parent)->spacing();
}
}
-
+//! [12]
diff --git a/examples/layouts/flowlayout/flowlayout.h b/examples/layouts/flowlayout/flowlayout.h
index 9940e55..bab7f36 100644
--- a/examples/layouts/flowlayout/flowlayout.h
+++ b/examples/layouts/flowlayout/flowlayout.h
@@ -45,7 +45,7 @@
#include <QLayout>
#include <QRect>
#include <QWidgetItem>
-
+//! [0]
class FlowLayout : public QLayout
{
public:
@@ -74,5 +74,6 @@ private:
int m_hSpace;
int m_vSpace;
};
+//! [0]
#endif
diff --git a/examples/layouts/flowlayout/window.cpp b/examples/layouts/flowlayout/window.cpp
index 51d9886..b7d9eae 100644
--- a/examples/layouts/flowlayout/window.cpp
+++ b/examples/layouts/flowlayout/window.cpp
@@ -43,7 +43,7 @@
#include "flowlayout.h"
#include "window.h"
-
+//! [1]
Window::Window()
{
FlowLayout *flowLayout = new FlowLayout;
@@ -57,3 +57,4 @@ Window::Window()
setWindowTitle(tr("Flow Layout"));
}
+//! [1] \ No newline at end of file
diff --git a/examples/layouts/flowlayout/window.h b/examples/layouts/flowlayout/window.h
index ffd60af..77f8b6f 100644
--- a/examples/layouts/flowlayout/window.h
+++ b/examples/layouts/flowlayout/window.h
@@ -47,7 +47,7 @@
QT_BEGIN_NAMESPACE
class QLabel;
QT_END_NAMESPACE
-
+//! [0]
class Window : public QWidget
{
Q_OBJECT
@@ -55,5 +55,6 @@ class Window : public QWidget
public:
Window();
};
+//! [0]
#endif