Results 1 to 2 of 2

Thread: newbies here--the Qt tutorial textfinder does not work.

  1. #1
    Join Date
    Jan 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default newbies here--the Qt tutorial textfinder does not work.

    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 

  2. #2
    Join Date
    Jan 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: newbies here--the Qt tutorial textfinder does not work.

    I think I find the problem. The resource should include both .ui and .txt files.

Similar Threads

  1. Replies: 6
    Last Post: 2nd October 2011, 21:08
  2. Hello fellow newbies..
    By jlc in forum Newbie
    Replies: 1
    Last Post: 15th August 2010, 19:39
  3. Modified TextFinder example
    By LoomVortex in forum Newbie
    Replies: 4
    Last Post: 26th August 2009, 11:17
  4. Tutorial 7 and Dev-C++
    By swarm32 in forum Newbie
    Replies: 3
    Last Post: 2nd December 2007, 21:16
  5. QT tutorial 7
    By ranu in forum Qt Programming
    Replies: 4
    Last Post: 22nd May 2007, 06:05

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.