Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tobias Hunger
qt-creator
Commits
6aeb8a76
Commit
6aeb8a76
authored
Mar 24, 2009
by
hjk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more fixes to the textfinder example documentation
parent
a4bb415f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
doc/example/textfinder/textfinder.cpp
doc/example/textfinder/textfinder.cpp
+6
-0
doc/qtcreator.qdoc
doc/qtcreator.qdoc
+10
-16
doc/qtcreator.qdocconf
doc/qtcreator.qdocconf
+1
-0
No files found.
doc/example/textfinder/textfinder.cpp
View file @
6aeb8a76
...
...
@@ -33,18 +33,21 @@
#include <QtCore/QTextStream>
#include <QtGui/QMessageBox>
//! [2]
TextFinder
::
TextFinder
(
QWidget
*
parent
)
:
QWidget
(
parent
),
ui
(
new
Ui
::
TextFinder
)
{
ui
->
setupUi
(
this
);
loadTextFile
();
}
//! [2]
TextFinder
::~
TextFinder
()
{
delete
ui
;
}
//! [0]
void
TextFinder
::
loadTextFile
()
{
QFile
inputFile
(
":/input.txt"
);
...
...
@@ -58,9 +61,12 @@ void TextFinder::loadTextFile()
QTextCursor
cursor
=
ui
->
textEdit
->
textCursor
();
cursor
.
movePosition
(
QTextCursor
::
Start
,
QTextCursor
::
MoveAnchor
,
1
);
}
//! [0]
//! [1]
void
TextFinder
::
on_findButton_clicked
()
{
QString
searchString
=
ui
->
lineEdit
->
text
();
ui
->
textEdit
->
find
(
searchString
,
QTextDocument
::
FindWholeWords
);
}
//! [1]
doc/qtcreator.qdoc
View file @
6aeb8a76
...
...
@@ -565,7 +565,7 @@
void loadTextFile();
\endcode
\note The \c{Ui::
Form
} object is already provided.
\note The \c{Ui::
TextFinder
} object is already provided.
\section2 The Source File
...
...
@@ -573,9 +573,7 @@
\c{textfinder.cpp}. We begin by filling in the functionality to load a
text file. The code snippet below describes this:
\quotefromfile textfinder.cpp
\skipto TextFinder::loadTextFile
\printuntil }
\snippet example/textfinder/textfinder.cpp 0
Basically, we load a text file using
\l{http://doc.trolltech.com/qfile.html}{QFile}, read it with
...
...
@@ -593,22 +591,18 @@
to look for the search string within the text file. The code snippet below
further describes it:
\quotefromfile textfinder.cpp
\skipto on_findButton_clicked
\printuntil }
\snippet example/textfinder/textfinder.cpp 1
Once we have both these functions complete, we call \c{loadTextFile()} in
our constructor.
\quotefromfile textfinder.cpp
\skipto TextFinder::TextFinder
\printuntil }
\snippet example/textfinder/textfinder.cpp 2
The \c{on_findButton_clicked()} slot will be called automatically due to
this line of code:
\code
QMetaObject::connectSlotsByName(TextFinder
Class
);
QMetaObject::connectSlotsByName(TextFinder);
\endcode
in the uic generated \c{ui_textfinder.h} file.
...
...
@@ -1184,13 +1178,13 @@
\code
void TextFinder::on_findButton_clicked()
{
QString searchString = ui
.
lineEdit->text();
QString searchString = ui
->
lineEdit->text();
QTextDocument *document = ui
.
textEdit->document();
QTextCursor cursor = ui
.
textEdit->textCursor();
QTextDocument *document = ui
->
textEdit->document();
QTextCursor cursor = ui
->
textEdit->textCursor();
cursor = document->find(searchString, cursor,
QTextDocument::FindWholeWords);
ui
.
textEdit->setTextCursor(cursor);
ui
->
textEdit->setTextCursor(cursor);
bool found = cursor.isNull();
...
...
@@ -1203,7 +1197,7 @@
if (ret == QMessageBox::Yes) {
cursor = document->find(searchString,
QTextDocument::FindWholeWords);
ui
.
textEdit->setTextCursor(cursor);
ui
->
textEdit->setTextCursor(cursor);
} else
return;
}
...
...
doc/qtcreator.qdocconf
View file @
6aeb8a76
...
...
@@ -8,6 +8,7 @@ sourcedirs =
sourcedirs = $SRCDIR
imagedirs = $SRCDIR
outputdir = $OUTDIR
exampledirs = $SRCDIR
extraimages.HTML = qt-logo \
trolltech-logo
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment