summaryrefslogtreecommitdiffstats
path: root/doc/src
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-05-04 15:21:02 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-05-04 15:21:02 (GMT)
commit793d3c2da83098e32063c4ae6df187058103bde8 (patch)
tree7b96581a67bd66ff30b0ede18b0fbfd71d9345cf /doc/src
parent2d0f49df3a3c44601bf2e41ea722c2384b71aab0 (diff)
parentc2d47f6717fdccd44838f3c128693a3c09f6cf68 (diff)
downloadQt-793d3c2da83098e32063c4ae6df187058103bde8.zip
Qt-793d3c2da83098e32063c4ae6df187058103bde8.tar.gz
Qt-793d3c2da83098e32063c4ae6df187058103bde8.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into windows-7-multitouch
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/designer-manual.qdoc12
-rw-r--r--doc/src/examples/flowlayout.qdoc115
-rw-r--r--doc/src/exportedfunctions.qdoc3
-rw-r--r--doc/src/images/flowlayout-example.pngbin5054 -> 29350 bytes
-rw-r--r--doc/src/layout.qdoc2
-rw-r--r--doc/src/qnamespace.qdoc8
6 files changed, 131 insertions, 9 deletions
diff --git a/doc/src/designer-manual.qdoc b/doc/src/designer-manual.qdoc
index 97713b1..2706182 100644
--- a/doc/src/designer-manual.qdoc
+++ b/doc/src/designer-manual.qdoc
@@ -344,10 +344,14 @@
of a QLineEdit or the width and height of item view widgets. This is where
the widget size constraints -- \l{QWidget::minimumSize()}{minimumSize} and
\l{QWidget::maximumSize()}{maximumSize} constraints come into play. These
- are properties you can set in the property editor. Alternatively, to use
- the current size as a size constraint value, choose one of the
- \gui{Size Constraint} options from the widget's context menu. The layout
- will then ensure that those constraints are met.
+ are properties you can set in the property editor. For example, to override
+ the default \l{QWidget::}{sizeHint()}, simply set
+ \l{QWidget::minimumSize()}{minimumSize} and \l{QWidget::maximumSize()}
+ {maximumSize} to the same value. Alternatively, to use the current size as
+ a size constraint value, choose one of the \gui{Size Constraint} options
+ from the widget's context menu. The layout will then ensure that those
+ constraints are met. To control the size of your widgets via code, you can
+ reimplement \l{QWidget::}{sizeHint()} in your code.
The screenshot below shows the breakdown of a basic user interface designed
using a grid. The coordinates on the screenshot show the position of each
diff --git a/doc/src/examples/flowlayout.qdoc b/doc/src/examples/flowlayout.qdoc
index 557ba39..3e7ec22 100644
--- a/doc/src/examples/flowlayout.qdoc
+++ b/doc/src/examples/flowlayout.qdoc
@@ -43,8 +43,117 @@
\example layouts/flowlayout
\title Flow Layout Example
- The Flow Layout example demonstrates a custom layout that arranges child widgets from
- left to right and top to bottom in a top-level widget.
+ The Flow Layout example demonstrates a custom layout that arranges child
+ widgets from left to right and top to bottom in a top-level widget.
+
+ \image flowlayout-example.png Screenshot of the Flow Layout example
+
+ The items are first laid out horizontally and then vertically when each line
+ in the layout runs out of space.
+
+ The Flowlayout class mainly uses QLayout and QWidgetItem, while the
+ Window uses QWidget and QLabel. We will only document the definition
+ and implementation of \c FlowLayout below.
+
+ \section1 FlowLayout Class Definition
+
+ The \c FlowLayout class inherits QLayout. It is a custom layout class
+ that arranges its child widgets horizontally and vertically.
+
+ \snippet examples/layouts/flowlayout/flowlayout.h 0
+
+ We reimplement functions inherited from QLayout. These functions add items to
+ the layout and handle their orientation and geometry.
+
+ We also declare two private methods, \c doLayout() and \c smartSpacing().
+ \c doLayout() lays out the layout items, while the \c
+ smartSpacing() function calculates the spacing between them.
+
+ \section1 FlowLayout Class Implementation
+
+ We start off by looking at the constructor:
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 1
+
+ In the constructor we call \c setContentsMargins() to set the left, top,
+ right and bottom margin. By default, QLayout uses values provided by
+ the current style (see QStyle::PixelMetric).
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 2
+
+ In this example we reimplement \c addItem(), which is a pure virtual
+ function. When using \c addItem() the ownership of the layout items is
+ transferred to the layout, and it is therefore the layout's
+ responsibility to delete them.
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 3
+
+ \c addItem() is implemented to add items to the layout.
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 4
+
+ We implement \c horizontalSpacing() and \c verticalSpacing() to get
+ hold of the spacing between the widgets inside the layout. If the value
+ is less than or equal to 0, this value will be used. If not,
+ \c smartSpacing() will be called to calculate the spacing.
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 5
+
+ We then implement \c count() to return the number of items in the
+ layout. To navigate the list of items we use \c itemAt() and
+ takeAt() to remove and return items from the list. If an item is
+ removed, the remaining items will be renumbered. All three
+ functions are pure virtual functions from QLayout.
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 6
+
+ \c expandingDirections() returns the \l{Qt::Orientation}s in which the
+ layout can make use of more space than its \c sizeHint().
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 7
+
+ To adjust to widgets of which height is dependent on width, we implement \c
+ heightForWidth(). The function \c hasHeightForWidth() is used to test for this
+ dependency, and \c heightForWidth() passes the width on to \c doLayout() which
+ in turn uses the width as an argument for the layout rect, i.e., the bounds in
+ which the items are laid out. This rect does not include the layout margin().
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 8
+
+ \c setGeometry() is normally used to do the actual layout, i.e., calculate
+ the geometry of the layout's items. In this example, it calls \c doLayout()
+ and passes the layout rect.
+
+ \c sizeHint() returns the preferred size of the layout and \c minimumSize()
+ returns the minimum size of the layout.
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 9
+
+ \c doLayout() handles the layout if \c horizontalSpacing() or \c
+ verticalSpacing() don't return the default value. It uses
+ \c getContentsMargins() to calculate the area available to the
+ layout items.
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 10
+
+ It then sets the proper amount of spacing for each widget in the
+ layout, based on the current style.
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 11
+
+ The position of each item in the layout is then calculated by
+ adding the items width and the line height to the initial x and y
+ coordinates. This in turn lets us find out whether the next item
+ will fit on the current line or if it must be moved down to the next.
+ We also find the height of the current line based on the widgets height.
+
+ \snippet examples/layouts/flowlayout/flowlayout.cpp 12
+
+ \c smartSpacing() is designed to get the default spacing for either
+ the top-level layouts or the sublayouts. The default spacing for
+ top-level layouts, when the parent is a QWidget, will be determined
+ by querying the style. The default spacing for sublayouts, when
+ the parent is a QLayout, will be determined by querying the spacing
+ of the parent layout.
- \image flowlayout-example.png
*/
diff --git a/doc/src/exportedfunctions.qdoc b/doc/src/exportedfunctions.qdoc
index f67950c..b421086 100644
--- a/doc/src/exportedfunctions.qdoc
+++ b/doc/src/exportedfunctions.qdoc
@@ -129,6 +129,9 @@
on Mac OS X or be part of the main window. This feature is on by
default.
+ In Qt 4.6, this is equivalent to
+ \c { QApplication::instance()->setAttribute(Qt::AA_MacDontUseNativeMenuBar); }.
+
\section1 void qt_mac_set_press_and_hold_context(bool \e{enable})
Turns emulation of the right mouse button by clicking and holding
diff --git a/doc/src/images/flowlayout-example.png b/doc/src/images/flowlayout-example.png
index 27660d6..61abe1f 100644
--- a/doc/src/images/flowlayout-example.png
+++ b/doc/src/images/flowlayout-example.png
Binary files differ
diff --git a/doc/src/layout.qdoc b/doc/src/layout.qdoc
index 38163c8..55dfd8b 100644
--- a/doc/src/layout.qdoc
+++ b/doc/src/layout.qdoc
@@ -371,7 +371,7 @@
should store the value in a local variable if you need it again
later within in the same function.
\o You should not call QLayoutItem::setGeometry() twice on the same
- item in the smae function. This call can be very expensive if the
+ item in the same function. This call can be very expensive if the
item has several child widgets, because the layout manager must do
a complete layout every time. Instead, calculate the geometry and
then set it. (This does not only apply to layouts, you should do
diff --git a/doc/src/qnamespace.qdoc b/doc/src/qnamespace.qdoc
index 3045d3f..75bd547 100644
--- a/doc/src/qnamespace.qdoc
+++ b/doc/src/qnamespace.qdoc
@@ -149,7 +149,13 @@
\value AA_MacPluginApplication Stops the a Qt mac application from doing
specific initializations that do not necessarily make sense when using Qt
to author a plugin. This includes avoiding loading our nib for the main
- menu and not taking possession of the native menu bar.
+ menu and not taking possession of the native menu bar. When setting this
+ attribute to true will alse set the AA_MacDontUseNativeMenuBar attribute
+ to true.
+
+ \value AA_DontUseNativeMenuBar All menubars created while this attribute is
+ set to true won't be used as a native menubar (e.g, the menubar at
+ the top of the main screen on Mac OS X or at the bottom in Windows CE).
\omitvalue AA_AttributeCount
*/