Hi I am just new to the qt programming, what I did is just the tut of qt textfinder. Now it can be compiled, however there is no text showed in the textedit part, does anybody know what mistakes I make?
Here is the code:
Qt Code:
  1. #include "textfinder.h"
  2. #include "ui_textfinder.h"
  3. #include <QFile>
  4. #include <QTextStream>
  5. #include <QWidget>
  6.  
  7. textfinder::textfinder(QWidget *parent) :
  8. QWidget(parent),
  9. ui(new Ui::textfinder)
  10. {
  11. ui->setupUi(this);
  12. loadTextFile();
  13. //QMetaObject::connectSlotsByName(this);
  14. }
  15.  
  16. textfinder::~textfinder()
  17. {
  18. delete ui;
  19. }
  20.  
  21. void textfinder::loadTextFile()
  22. {
  23. QFile inputFile(":/input.txt");
  24. inputFile.open(QIODevice::ReadOnly);
  25.  
  26. QTextStream in(&inputFile);
  27. QString line = in.readAll();
  28. inputFile.close();
  29.  
  30. ui->textEdit->setPlainText(line);
  31. QTextCursor cursor = ui->textEdit->textCursor();
  32. cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor, 1);
  33. }
  34.  
  35. void textfinder::on_findButton_clicked()
  36. {
  37. QString searchString = ui->lineEdit->text();
  38. ui->textEdit->find(searchString, QTextDocument::FindWholeWords);
  39. }
To copy to clipboard, switch view to plain text mode