Skip to content

Instantly share code, notes, and snippets.

@mirosht
Created December 1, 2014 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirosht/a736b611d3e79863c5e5 to your computer and use it in GitHub Desktop.
Save mirosht/a736b611d3e79863c5e5 to your computer and use it in GitHub Desktop.
#include <QtCore/QFile>
#include <QtCore/QTextStream>
#include "wordfinder.h"
#include "ui_wordfinder.h"
WordFinder::WordFinder(QWidget *parent) :
QWidget(parent),
ui(new Ui::WordFinder)
{
ui->setupUi(this);
}
WordFinder::~WordFinder()
{
delete ui;
}
void WordFinder::on_FindButton_clicked()
{
QString word = ui->lineEdit->text();
ui->textEdit->find(word, QTextDocument::FindWholeWords);
}
void WordFinder:: getTexFile(){
QFile myFile(":/text.txt");
myFile.open(QIODevice::ReadOnly);
QTextStream textStream(&myFile);
QString line = textStream.readAll();
&QFileDevice::close;
ui->textEdit-> setPlainText(line); /*desplays text in text area*/
QTextCursor textCursor = ui->textEdit->textCursor();
textCursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment