summaryrefslogtreecommitdiffstats
path: root/examples/layouts
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-05-06 06:55:50 (GMT)
committeraxis <qt-info@nokia.com>2009-05-06 06:55:50 (GMT)
commitb246f8a8beab858468777f433f49faf62edcb07e (patch)
tree120844101aca654bf2f69fef5ea2647bf0bee13a /examples/layouts
parent5791fde8526afc49cdbeee080ead9e8a305e3cd5 (diff)
parenta1d2c3c589a03cc427dcc22d109003576add9500 (diff)
downloadQt-b246f8a8beab858468777f433f49faf62edcb07e.zip
Qt-b246f8a8beab858468777f433f49faf62edcb07e.tar.gz
Qt-b246f8a8beab858468777f433f49faf62edcb07e.tar.bz2
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'examples/layouts')
-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