Results 1 to 11 of 11

Thread: Qt4.5 windows TextFind tutorial not working

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt4.5 windows TextFind tutorial not working

    I`m sorry but really i tryed everything. in comment are ways how I tryed. is compiling, text editor is filled in text but button not working as well cursor is not changing.
    every widget is add in creator, how to make connect() working?
    Qt Code:
    1. widget.cpp
    2. //**************************************************************
    3. #include <QtCore/QFile>
    4. #include <QtCore/QTextStream>
    5. #include "widget.h"
    6. #include "ui_widget.h"
    7.  
    8. Widget::Widget(QWidget *parent)
    9. : QWidget(parent), ui(new Ui::Widget)
    10. {
    11. ui->setupUi(this);
    12. loadTextFile();
    13. //QObject::connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(huj()));
    14. //connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(huj()));
    15. //QMetaObject::connectSlotsByName(this);
    16. }
    17.  
    18. Widget::~Widget()
    19. {
    20. delete ui;
    21. }
    22. void Widget::loadTextFile()
    23. {
    24. QFile inputFile(":/input.txt");
    25. inputFile.open(QIODevice::ReadOnly);
    26.  
    27. QTextStream in(&inputFile);
    28. QString line = in.readAll();
    29. inputFile.close();
    30.  
    31. ui->textEdit->setPlainText(line);
    32. QTextCursor cursor = ui->textEdit->textCursor();
    33. cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor, 1);
    34. }
    35. void Widget::on_pushButton_clicked()
    36. {//ui->label->text()="huj";
    37. QString searchString = ui->lineEdit->text();
    38. ui->textEdit->find(searchString, QTextDocument::FindWholeWords);
    39. }
    40. void Widget::huj()
    41. {//ui->label->text()="huj";
    42. QString searchString = ui->lineEdit->text();
    43. ui->textEdit->find(searchString, QTextDocument::FindWholeWords);
    44. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. widget.h
    2. //***********************************************************
    3. #ifndef WIDGET_H
    4. #define WIDGET_H
    5.  
    6. #include <QtGui/QWidget>
    7.  
    8. namespace Ui
    9. {
    10. class Widget;
    11. }
    12. class Widget : public QWidget
    13. {
    14. Q_OBJECT
    15.  
    16. public:
    17. Widget(QWidget *parent = 0);
    18. ~Widget();
    19.  
    20. public slots:
    21. void on_pushButton_clicked();
    22. void huj();
    23. private:
    24. Ui::Widget *ui;
    25.  
    26. void loadTextFile();
    27. //void QMetaObject::connectSlotsByName(ui);
    28. };
    29. #endif // WIDGET_H
    To copy to clipboard, switch view to plain text mode 
    Last edited by czlowiekcien; 25th May 2009 at 08:29.

Similar Threads

  1. Getting Phonon working on windows XP
    By keshava in forum Installation and Deployment
    Replies: 0
    Last Post: 12th May 2009, 16:37
  2. Windows fonts not working in QT?
    By frenetic in forum Installation and Deployment
    Replies: 2
    Last Post: 10th January 2009, 02:17

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
  •  
Qt is a trademark of The Qt Company.