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
parent
2870c201dc
commit
8ff63383e4
|
|
@ -3,6 +3,6 @@ SUBDIRS =
|
|||
|
||||
contains(QT_BUILD_PARTS, tests) {
|
||||
SUBDIRS += \
|
||||
qfontdatabase
|
||||
qfontdatabase \
|
||||
textdocument-end
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
TEMPLATE = lib
|
||||
TARGET = textdocumentend_snippets
|
||||
QT += core gui widgets
|
||||
|
||||
SOURCES = textdocumentendsnippet.cpp
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue