Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
32495f55
Commit
32495f55
authored
16 years ago
by
hjk
Browse files
Options
Downloads
Patches
Plain Diff
more fixes to the example
parent
13dec817
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/qtcreator.qdoc
+15
-30
15 additions, 30 deletions
doc/qtcreator.qdoc
with
15 additions
and
30 deletions
doc/qtcreator.qdoc
+
15
−
30
View file @
32495f55
...
@@ -573,51 +573,36 @@
...
@@ -573,51 +573,36 @@
\c{textfinder.cpp}. We begin by filling in the functionality to load a
\c{textfinder.cpp}. We begin by filling in the functionality to load a
text file. The code snippet below describes this:
text file. The code snippet below describes this:
\code
\quotefromfile textfinder.cpp
void TextFinder::loadTextFile()
\skipto TextFinder::loadTextFile
{
\printuntil }
QFile inputFile(":/input.txt");
inputFile.open(QIODevice::ReadOnly);
QTextStream in(&inputFile);
QString line = in.readAll();
inputFile.close();
ui->textEdit->setPlainText(line);
QTextCursor cursor = ui->textEdit->textCursor();
}
\endcode
Basically, we load a text file using
Basically, we load a text file using
\l{http://doc.trolltech.com/qfile.html}{QFile}, read it with
\l{http://doc.trolltech.com/qfile.html}{QFile}, read it with
\l{http://doc.trolltech.com/qtextstream.html}{QTextStream}, and
\l{http://doc.trolltech.com/qtextstream.html}{QTextStream}, and
then display it on \c{textEdit} with
then display it on \c{textEdit} with
\l{http://doc.trolltech.com/qtextedit.html#plainText-prop}{setPlainText()}.
\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
For the \c{on_findButton_clicked()} slot, we extract the search string and
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
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
to look for the search string within the text file. The code snippet below
further describes it:
further describes it:
\code
\quotefromfile textfinder.cpp
void TextFinder::on_findButton_clicked()
\skipto on_findButton_clicked
{
\printuntil }
QString searchString = ui->lineEdit->text();
ui->textEdit->find(searchString, QTextDocument::FindWholeWords);
}
\endcode
Once we have both these functions complete, we call \c{loadTextFile()} in
Once we have both these functions complete, we call \c{loadTextFile()} in
our constructor.
our constructor.
\code
\quotefromfile textfinder.cpp
TextFinder::TextFinder(QWidget *parent)
\skipto TextFinder::TextFinder
: QWidget(parent)
\printuntil }
{
ui->setupUi(this);
loadTextFile();
}
\endcode
The \c{on_findButton_clicked()} slot will be called automatically due to
The \c{on_findButton_clicked()} slot will be called automatically due to
this line of code:
this line of code:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment