Doc: Compile textdocument-end snippets

* Extend GUI snippet compilation with textdocument-end snippet.
* Rename the snippet file and replace main() with wrapper().
* Dedent the snippet itself.
* Update documentation that includes the snippet.

Done-with: Nico Vertriest <nico.vertriest@qt.io>
Task-number: QTBUG-81486
Change-Id: Id5e5b284587da1e7fdfd00baa9c899626832a113
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
bb10
Paul Wicking 2020-08-20 15:10:59 +02:00
parent 2870c201dc
commit 8ff63383e4
4 changed files with 15 additions and 10 deletions

View File

@ -3,6 +3,6 @@ SUBDIRS =
contains(QT_BUILD_PARTS, tests) {
SUBDIRS += \
qfontdatabase
qfontdatabase \
textdocument-end
}

View File

@ -0,0 +1,5 @@
TEMPLATE = lib
TARGET = textdocumentend_snippets
QT += core gui widgets
SOURCES = textdocumentendsnippet.cpp

View File

@ -49,18 +49,18 @@
****************************************************************************/
#include <QtGui>
#include <iostream.h>
#include <iostream>
int main(int argv, char **args)
namespace textdocumentendsnippet {
void wrapper()
{
QString contentString("One\nTwp\nThree");
QTextDocument *doc = new QTextDocument(contentString);
//! [0]
for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next())
cout << it.text().toStdString() << Qt::endl;
for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next())
std::cout << it.text().toStdString() << "\n";
//! [0]
return 0;
}
} // wrapper
} //textdocumentendsnippet

View File

@ -1642,7 +1642,7 @@ QTextBlock QTextDocument::begin() const
This function returns a block to test for the end of the document
while iterating over it.
\snippet textdocumentendsnippet.cpp 0
\snippet textdocument-end/textdocumentendsnippet.cpp 0
The block returned is invalid and represents the block after the
last block in the document. You can use lastBlock() to retrieve the