diff options
Diffstat (limited to 'doc/src/widgets-and-layouts')
-rw-r--r-- | doc/src/widgets-and-layouts/layout.qdoc | 16 | ||||
-rw-r--r-- | doc/src/widgets-and-layouts/styles.qdoc | 14 | ||||
-rw-r--r-- | doc/src/widgets-and-layouts/stylesheet.qdoc | 30 |
3 files changed, 30 insertions, 30 deletions
diff --git a/doc/src/widgets-and-layouts/layout.qdoc b/doc/src/widgets-and-layouts/layout.qdoc index c3db5fa..1d8214b 100644 --- a/doc/src/widgets-and-layouts/layout.qdoc +++ b/doc/src/widgets-and-layouts/layout.qdoc @@ -319,16 +319,16 @@ \section2 The Header File (\c card.h) - \snippet doc/src/snippets/code/doc_src_layout.qdoc 0 + \snippet doc/src/snippets/code/doc_src_layout.cpp 0 \section2 The Implementation File (\c card.cpp) - \snippet doc/src/snippets/code/doc_src_layout.qdoc 1 + \snippet doc/src/snippets/code/doc_src_layout.cpp 1 First we define \c{count()} to fetch the number of items in the list. - \snippet doc/src/snippets/code/doc_src_layout.qdoc 2 + \snippet doc/src/snippets/code/doc_src_layout.cpp 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 @@ -341,7 +341,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 3 + \snippet doc/src/snippets/code/doc_src_layout.cpp 3 \c{addItem()} implements the default placement strategy for layout items. This function must be implemented. It is used by QLayout::add(), by the @@ -351,26 +351,26 @@ QGridLayout::addItem(), QGridLayout::addWidget(), and QGridLayout::addLayout(). - \snippet doc/src/snippets/code/doc_src_layout.qdoc 4 + \snippet doc/src/snippets/code/doc_src_layout.cpp 4 The layout takes over responsibility of the items added. Since QLayoutItem does not inherit QObject, we must delete the items manually. In the destructor, we remove each item from the list using \c{takeAt()}, and then delete it. - \snippet doc/src/snippets/code/doc_src_layout.qdoc 5 + \snippet doc/src/snippets/code/doc_src_layout.cpp 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 6 + \snippet doc/src/snippets/code/doc_src_layout.cpp 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 7 + \snippet doc/src/snippets/code/doc_src_layout.cpp 7 \section2 Further Notes diff --git a/doc/src/widgets-and-layouts/styles.qdoc b/doc/src/widgets-and-layouts/styles.qdoc index 8231fcb..9e9dd64 100644 --- a/doc/src/widgets-and-layouts/styles.qdoc +++ b/doc/src/widgets-and-layouts/styles.qdoc @@ -283,12 +283,12 @@ pointer type is correct. If the object isn't of the right type, qstyleoption_cast() returns 0. For example: - \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 0 The following code snippet illustrates how to use QStyle to draw the focus rectangle from a custom widget's paintEvent(): - \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 1 The next example shows how to derive from an existing style to customize the look of a graphical element: @@ -542,7 +542,7 @@ We start with a look at how QCheckBox builds it style option, which is QStyleOptionButton for checkboxes: - \snippet doc/src/snippets/code/doc_src_styles.qdoc 0 + \snippet doc/src/snippets/code/doc_src_styles.cpp 0 First we let QStyleOption set up the option with the information that is common for all widgets with \c initFrom(). We will look at @@ -561,7 +561,7 @@ attributes that are common for all widgets. We print its implementation here: - \snippet doc/src/snippets/code/doc_src_styles.qdoc 1 + \snippet doc/src/snippets/code/doc_src_styles.cpp 1 The State_Enabled is set when the widget is enabled. When the widget has focus the State_HasFocus flag is set. Equally, the @@ -625,7 +625,7 @@ notably, it wraps the methods in QStyle used for painting. The QCheckBox draws itself as follows: - \snippet doc/src/snippets/code/doc_src_styles.qdoc 2 + \snippet doc/src/snippets/code/doc_src_styles.cpp 2 QCommonStyle handles the CE_CheckBox element. The QCheckBox has two sub elements: SE_CheckBoxIndicator (the checked indicator) @@ -633,7 +633,7 @@ checkbox label). QCommonStyle also implements these sub element bounding rectangles. We have a look at the QCommonStyle code: - \snippet doc/src/snippets/code/doc_src_styles.qdoc 3 + \snippet doc/src/snippets/code/doc_src_styles.cpp 3 As can be seen from the code extract, the common style gets the bounding rectangles of the two sub elements of @@ -644,7 +644,7 @@ handles CE_CheckboxLabel. We will examine each implementation and start with CE_CheckBoxLabel: - \snippet doc/src/snippets/code/doc_src_styles.qdoc 4 + \snippet doc/src/snippets/code/doc_src_styles.cpp 4 \l{QStyle::}{visualAlignment()} adjusts the alignment of text according to the layout direction. We then draw an icon if it diff --git a/doc/src/widgets-and-layouts/stylesheet.qdoc b/doc/src/widgets-and-layouts/stylesheet.qdoc index be845c4..8cfa2b4 100644 --- a/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -469,11 +469,11 @@ sheet. Consider the following example. First, we set a style sheet on the QApplication: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 21 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 21 Then we set a style sheet on a QPushButton object: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 22 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 22 The style sheet on the QPushButton forces the QPushButton (and any child widget) to have blue text, in spite of the more @@ -481,7 +481,7 @@ The result would have been the same if we had written - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 23 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 23 except that if the QPushButton had children (which is unlikely), the style sheet would have no impact on them. @@ -500,14 +500,14 @@ For example, consider a QPushButton inside a QGroupBox: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 24 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 24 The QPushButton does not have an explicit color set. Hence, instead of inheriting color of its parent QGroupBox, it has the system color. If we want to set the color on a QGroupBox and its children, we can write: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 25 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 25 In contrast, setting a font and propagate using QWidget::setFont() and QWidget::setPalette() propagates to child widgets. @@ -517,7 +517,7 @@ The Type Selector can be used to style widgets of a particular type. For example, - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 26 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 26 Qt Style Sheet uses QObject::className() of the widget to determine when to apply the Type Selector. When custom widgets are inside namespaces, @@ -526,7 +526,7 @@ when using the Type Selector for widgets inside namespaces, we must replace the "::" with "--". For example, - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 27 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 27 \section1 Setting QObject properties @@ -1328,7 +1328,7 @@ If you subclass from QWidget, you need to provide a paintEvent for your custom QWidget as below: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 32 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 32 The above code is a no-operation if there is no stylesheet set. @@ -3373,35 +3373,35 @@ \l{QLineEdit}s in an application. This could be achieved like this: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 88 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 88 If we want the property to apply only to the \l{QLineEdit}s that are children (or grandchildren or grand-grandchildren) of a specific dialog, we would rather do this: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 89 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 89 If we want the property to apply only to one specific QLineEdit, we can give it a name using QObject::setObjectName() and use an ID Selector to refer to it: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 90 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 90 Alternatively, we can set the \l{Qt Style Sheets Reference#background-prop}{background-color} property directly on the QLineEdit, omitting the selector: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 91 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 91 To ensure a good contrast, we should also specify a suitable color for the text: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 92 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 92 It might be a good idea to change the colors used for selected text as well: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 93 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 93 \section2 Customizing Using Dynamic Properties @@ -3422,7 +3422,7 @@ \c mandatoryField property on the fly and set it to true. For example: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 95 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 95 \section2 Customizing a QPushButton Using the Box Model |