Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
a4bb415f
Commit
a4bb415f
authored
Mar 24, 2009
by
hjk
Browse files
update textfinder example
parent
32495f55
Changes
3
Hide whitespace changes
Inline
Side-by-side
doc/example/textfinder/textfinder.cpp
View file @
a4bb415f
...
...
@@ -33,16 +33,16 @@
#include
<QtCore/QTextStream>
#include
<QtGui/QMessageBox>
TextFinder
::
TextFinder
(
QWidget
*
parent
,
Qt
::
WFlags
flags
)
:
QWidget
(
parent
,
flags
)
TextFinder
::
TextFinder
(
QWidget
*
parent
)
:
QWidget
(
parent
)
,
ui
(
new
Ui
::
TextFinder
)
{
ui
.
setupUi
(
this
);
ui
->
setupUi
(
this
);
loadTextFile
();
isFirstTime
=
true
;
}
TextFinder
::~
TextFinder
()
{
delete
ui
;
}
void
TextFinder
::
loadTextFile
()
...
...
@@ -54,20 +54,13 @@ void TextFinder::loadTextFile()
QString
line
=
in
.
readAll
();
inputFile
.
close
();
ui
.
textEdit
->
setPlainText
(
line
);
QTextCursor
cursor
=
ui
.
textEdit
->
textCursor
();
ui
->
textEdit
->
setPlainText
(
line
);
QTextCursor
cursor
=
ui
->
textEdit
->
textCursor
();
cursor
.
movePosition
(
QTextCursor
::
Start
,
QTextCursor
::
MoveAnchor
,
1
);
}
void
TextFinder
::
on_findButton_clicked
()
{
QString
searchString
=
ui
.
lineEdit
->
text
();
QTextDocument
*
document
=
ui
.
textEdit
->
document
();
bool
found
=
false
;
ui
.
textEdit
->
find
(
searchString
,
QTextDocument
::
FindWholeWords
);
QTextCursor
cursor
=
ui
.
textEdit
->
textCursor
();
if
(
!
cursor
.
isNull
())
found
=
true
;
QString
searchString
=
ui
->
lineEdit
->
text
();
ui
->
textEdit
->
find
(
searchString
,
QTextDocument
::
FindWholeWords
);
}
doc/example/textfinder/textfinder.h
View file @
a4bb415f
...
...
@@ -34,29 +34,25 @@
#include
<QtGui/QWidget>
class
QPushButton
;
class
QTextEdit
;
class
QLineEdit
;
namespace
Ui
{
class
TextFinder
;
}
class
TextFinder
:
public
QWidget
{
Q_OBJECT
public:
TextFinder
(
QWidget
*
parent
=
0
,
Qt
::
WFlags
flags
=
0
);
TextFinder
(
QWidget
*
parent
=
0
);
~
TextFinder
();
private
slots
:
void
on_findButton_clicked
();
private:
Ui
::
Form
ui
;
Ui
::
TextFinder
*
ui
;
void
loadTextFile
();
QPushButton
*
ui_findButton
;
QTextEdit
*
ui_textEdit
;
QLineEdit
*
ui_lineEdit
;
bool
isFirstTime
;
};
#endif // TEXTFINDER_H
doc/qtcreator.qdoc
View file @
a4bb415f
...
...
@@ -608,7 +608,7 @@
this line of code:
\code
QMetaObject::connectSlotsByName(
Form
);
QMetaObject::connectSlotsByName(
TextFinderClass
);
\endcode
in the uic generated \c{ui_textfinder.h} file.
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment