Results 1 to 11 of 11

Thread: Qt4.5 windows TextFind tutorial not working

  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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4.5 windows TextFind tutorial not working

    QLabel::text() is a getter, not a setter. The code shouldn't even compile.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt4.5 windows TextFind tutorial not working

    so I commented that and also this is not working

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4.5 windows TextFind tutorial not working

    Do you get any warnings in the console about the connect() statements? How do you know the code doesn't work?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt4.5 windows TextFind tutorial not working

    QObject::connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(huj()));
    this is compiling but nothing happens when I press the button, the button even not going down (is freeze).
    QObject::connect(ui->pushButton,SIGNAL(clicked()),ui,SLOT(huj()));

    is saying "no maching function for call..."
    in creator I cant set connection by clicking becouse he didnt see my slots

    I have good news
    QObject::connect(ui->lineEdit,SIGNAL(returnPressed()),this,SLOT(huj()) );

    this is working, but why manualy connected button with signal clicked not working? and why on_pushButton_clicked() is not connecting automatycaly even if I use //QMetaObject::connectSlotsByName(this);

    that metod is the last method in setupUi so i dont must to type it. what is wrong here?
    Last edited by czlowiekcien; 25th May 2009 at 09:07.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4.5 windows TextFind tutorial not working

    Can we see the whole message you are getting?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt4.5 windows TextFind tutorial not working

    when i using
    QObject::connect(ui->pushButton,SIGNAL(clicked()),ui,SLOT(huj()));

    widget.cpp:12: error: no matching function for call to `Widget::connect(QPushButton*&, const char*, Ui::Widget*&, const char*)'

    M:/Qt/projekty/textfajnd/TextFind/../../../2009.02/qt/include/QtCore/../../src/corelib/kernel/qobject.h:202: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)

    M:/Qt/projekty/textfajnd/TextFind/../../../2009.02/qt/include/QtCore/../../src/corelib/kernel/qobject.h:308: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const


    that is working well
    QObject::connect(ui->lineEdit,SIGNAL(returnPressed()),this,SLOT(huj()) );

  8. #8
    Join Date
    May 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt4.5 windows TextFind tutorial not working

    now I`m confused 7 hour of searching what is wrong for nothing. I create another button and it was working fine so I check properties and was everething the same so I delete first button and create it again and it is working. so admin can close that subject. thanks for helping

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4.5 windows TextFind tutorial not working

    Hmm... you said it was working well - I thought you found the problem. If not then I can tell you what was wrong - "ui" is not a widget thus passing "ui" as the third parameter to connect() is illegal.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    May 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt4.5 windows TextFind tutorial not working

    I type ui there becouse I trying to find any way to solve my problem I know that was wrong but I still dont know why I had that problem. maybe Qt Creator is not the best tool

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt4.5 windows TextFind tutorial not working

    Qt Creator is just a text editor, it doesn't make syntax errors - you do
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.