diff --git a/doc/examples/textfinder/textfinder.cpp b/doc/examples/textfinder/textfinder.cpp index c302f91911f79958f78241fd3b1d3d8f4cfee77e..0c5b39c921801f65c4bc887f22be65d9abce1629 100644 --- a/doc/examples/textfinder/textfinder.cpp +++ b/doc/examples/textfinder/textfinder.cpp @@ -29,18 +29,20 @@ #include "textfinder.h" +//! [1] #include <QtCore/QFile> #include <QtCore/QTextStream> +//! [1] #include <QtGui/QMessageBox> -//! [2] +//! [3] TextFinder::TextFinder(QWidget *parent) : QWidget(parent), ui(new Ui::TextFinder) { ui->setupUi(this); loadTextFile(); } -//! [2] +//! [3] TextFinder::~TextFinder() { @@ -63,10 +65,10 @@ void TextFinder::loadTextFile() } //! [0] -//! [1] +//! [2] void TextFinder::on_findButton_clicked() { QString searchString = ui->lineEdit->text(); ui->textEdit->find(searchString, QTextDocument::FindWholeWords); } -//! [1] +//! [2] diff --git a/doc/examples/textfinder/textfinder.h b/doc/examples/textfinder/textfinder.h index 89dad6913664d898a3d5ccd25f54a1d4a65c2d67..218ac28ce60f99a4719ed16fe5ce9f4a930a1c8a 100644 --- a/doc/examples/textfinder/textfinder.h +++ b/doc/examples/textfinder/textfinder.h @@ -47,12 +47,14 @@ public: TextFinder(QWidget *parent = 0); ~TextFinder(); +//! [0] private slots: void on_findButton_clicked(); private: Ui::TextFinder *ui; void loadTextFile(); +//! [0] }; #endif // TEXTFINDER_H diff --git a/doc/qtcreator.qdoc b/doc/qtcreator.qdoc index e4c97f7e35c8e6daf166d9afc3fe32c7d5c51104..325e91cb9696161e30d2a607625012606f75ffa7 100644 --- a/doc/qtcreator.qdoc +++ b/doc/qtcreator.qdoc @@ -564,15 +564,7 @@ \l{http://doc.trolltech.com/qtextedit.html}{QTextEdit}. This is done with the following code: - \code - private slots: - void on_findButton_clicked(); - - private: - Ui::TextFinder *ui; - void loadTextFile(); - \endcode - + \snippet examples/textfinder/textfinder.h 0 \note The \c{Ui::TextFinder} object is already provided. \section2 The Source File @@ -581,7 +573,7 @@ \c{textfinder.cpp}. We begin by filling in the functionality to load a text file. The code snippet below describes this: - \snippet example/textfinder/textfinder.cpp 0 + \snippet examples/textfinder/textfinder.cpp 0 Basically, we load a text file using \l{http://doc.trolltech.com/qfile.html}{QFile}, read it with @@ -589,22 +581,20 @@ then display it on \c{textEdit} with \l{http://doc.trolltech.com/qtextedit.html#plainText-prop}{setPlainText()} which requires adding the following additional #includes to textfinder.cpp: - \code - #include <QtCore/QFile> - #include <QtCore/QTextStream> - \endcode + + \snippet examples/textfinder/textfinder.cpp 1 For the \c{on_findButton_clicked()} slot, we extract the search string and use the \l{http://doc.trolltech.com/qtextedit.html#find}{find()} function to look for the search string within the text file. The code snippet below further describes it: - \snippet example/textfinder/textfinder.cpp 1 + \snippet examples/textfinder/textfinder.cpp 2 Once we have both these functions complete, we call \c{loadTextFile()} in our constructor. - \snippet example/textfinder/textfinder.cpp 2 + \snippet examples/textfinder/textfinder.cpp 3 The \c{on_findButton_clicked()} slot will be called automatically due to this line of code: