From 4410e66f455dd47a1de90dfd095849b9ecd32134 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 20 Aug 2012 15:17:13 +0200 Subject: Making trivial snippets inline Change-Id: I8d8b5586579d3ee460b234b5a09462586ac1cfd0 Reviewed-by: J-P Nurmi Reviewed-by: Jens Bache-Wiig Reviewed-by: Casper van Donderen --- examples/widgets/doc/application.qdoc | 6 +++++- examples/widgets/doc/editabletreemodel.qdoc | 8 ++++++-- examples/widgets/doc/icons.qdoc | 13 ++++++++++--- examples/widgets/doc/imageviewer.qdoc | 21 ++++++++++++++++----- examples/widgets/doc/simpletreemodel.qdoc | 12 ++++++++++-- 5 files changed, 47 insertions(+), 13 deletions(-) (limited to 'examples') diff --git a/examples/widgets/doc/application.qdoc b/examples/widgets/doc/application.qdoc index d99581fefd..4c537e293e 100644 --- a/examples/widgets/doc/application.qdoc +++ b/examples/widgets/doc/application.qdoc @@ -236,7 +236,11 @@ side of the menu bar. Try running the application with various styles and see the results: - \snippet doc/src/snippets/code/doc_src_examples_application.qdoc 0 + \code + application -style=windows + application -style=motif + application -style=cde + \endcode Let's now review the toolbars: diff --git a/examples/widgets/doc/editabletreemodel.qdoc b/examples/widgets/doc/editabletreemodel.qdoc index 423b9cee94..24745b77b8 100644 --- a/examples/widgets/doc/editabletreemodel.qdoc +++ b/examples/widgets/doc/editabletreemodel.qdoc @@ -132,14 +132,18 @@ In the case shown in the diagram, the piece of information represented by \b{a} can be obtained using the standard model/view API: - \snippet doc/src/snippets/code/doc_src_examples_editabletreemodel.cpp 0 + \code + QVariant a = model->index(0, 0, QModelIndex()).data(); + \endcode Since each items holds pieces of data for each column in a given row, there can be many model indexes that map to the same \c TreeItem object. For example, the information represented by \b{b} can be obtained using the following code: - \snippet doc/src/snippets/code/doc_src_examples_editabletreemodel.cpp 1 + \code + QVariant b = model->index(1, 0, QModelIndex()).data(); + \endcode The same underlying \c TreeItem would be accessed to obtain information for the other model indexes in the same row as \b{b}. diff --git a/examples/widgets/doc/icons.qdoc b/examples/widgets/doc/icons.qdoc index 2ccf8cac43..b6625db005 100644 --- a/examples/widgets/doc/icons.qdoc +++ b/examples/widgets/doc/icons.qdoc @@ -278,17 +278,24 @@ If the application is built in debug mode, the \c Q_ASSERT() macro will expand to - \snippet doc/src/snippets/code/doc_src_examples_icons.cpp 0 + \code + if (!condition) + qFatal("ASSERT: "condition" in file ..."); + \endcode In release mode, the macro simply disappear. The mode can be set in the application's \c .pro file. One way to do so is to add an option to \c qmake when building the application: - \snippet doc/src/snippets/code/doc_src_examples_icons.qdoc 1 + \code + qmake "CONFIG += debug" icons.pro + \endcode or - \snippet doc/src/snippets/code/doc_src_examples_icons.qdoc 2 + \code + qmake "CONFIG += release" icons.pro + \endcode Another approach is to add this line directly to the \c .pro file. diff --git a/examples/widgets/doc/imageviewer.qdoc b/examples/widgets/doc/imageviewer.qdoc index 8f8e238046..3556d52f7e 100644 --- a/examples/widgets/doc/imageviewer.qdoc +++ b/examples/widgets/doc/imageviewer.qdoc @@ -149,7 +149,9 @@ \{QWidget::adjustSize()}{adjustSize()} to achieve this, which is essentially the same as - \snippet doc/src/snippets/code/doc_src_examples_imageviewer.cpp 0 + \code + imageLabel->resize(imageLabel->pixmap()->size()); + \endcode In the \c print() slot, we first make sure that an image has been loaded into the application: @@ -160,17 +162,24 @@ If the application is built in debug mode, the \c Q_ASSERT() macro will expand to - \snippet doc/src/snippets/code/doc_src_examples_imageviewer.cpp 1 + \code + if (!imageLabel->pixmap()) + qFatal("ASSERT: "imageLabel->pixmap()" in file ..."); + \endcode In release mode, the macro simply disappear. The mode can be set in the application's \c .pro file. One way to do so is to add an option to \uicontrol qmake when building the application: - \snippet doc/src/snippets/code/doc_src_examples_imageviewer.qdoc 2 + \code + qmake "CONFIG += debug" foo.pro + \endcode or - \snippet doc/src/snippets/code/doc_src_examples_imageviewer.qdoc 3 + \code + qmake "CONFIG += release" foo.pro + \endcode Another approach is to add this line directly to the \c .pro file. @@ -318,7 +327,9 @@ Whenever we zoom in or out, we need to adjust the scroll bars in consequence. It would have been tempting to simply call - \snippet doc/src/snippets/code/doc_src_examples_imageviewer.cpp 4 + \code + scrollBar->setValue(int(factor * scrollBar->value())); + \endcode but this would make the top-left corner the focal point, not the center. Therefore we need to take into account the scroll bar diff --git a/examples/widgets/doc/simpletreemodel.qdoc b/examples/widgets/doc/simpletreemodel.qdoc index a2b6010441..c054352cb8 100644 --- a/examples/widgets/doc/simpletreemodel.qdoc +++ b/examples/widgets/doc/simpletreemodel.qdoc @@ -313,9 +313,17 @@ We begin with a text file in the following format: - \snippet doc/src/snippets/code/doc_src_examples_simpletreemodel.qdoc 0 + \code + Getting Started How to familiarize yourself with Qt Designer + Launching Designer Running the Qt Designer application + The User Interface How to interact with Qt Designer + \endcode \dots - \snippet doc/src/snippets/code/doc_src_examples_simpletreemodel.qdoc 1 + \code + Connection Editing Mode Connecting widgets together with signals and slots + Connecting Objects Making connections in Qt Designer + Editing Connections Changing existing connections + \endcode We process the text file with the following two rules: -- cgit v1.2.3