Qt textfinder tutorial issue
Hello, im a little (Or a big) noob to this QT Qt framework, and i trying to understand how it works. I was trying the Textfinder tutorial in QT Qt Creator, but without any succes. I have done all the tasks, but in the end, Im getting thís error:
- D:\QtSDK\Examples\TextFinder-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug\..\TextFinder\textfinder.cpp:19: error: no 'void TextFinder::on_findButton_clicked()' member function declared in class 'TextFinder'
My textfinder.cpp is looking like this:
- #include "textfinder.h"
- #include "ui_textfinder.h"
- #include <QtCore/QFile>
- #include <QtCore/QTextStream>
- ui(new Ui::TextFinder)
- {
- ui->setupUi(this);
- loadTextFile();
- }
- TextFinder::~TextFinder()
- {
- delete ui;
- }
- void TextFinder::on_findButton_clicked()
- {
- }
- void TextFinder::loadTextFile()
- {
- inputFile.close();
- ui->textEdit->setPlainText(line);
- }
Can someone explain what i had done wrong, and i apoligize for my bad english.
[EDIT: code formatting, please wrap in @-tags, Volker]
8 replies
You’re welcome. Please always keep in mind that C++ (and C) are case sensitive languages, so a variable x is not the same a variable X. Also this affects the autoconnection, so you should double check the exact spelling of your widget in the UI (upper or lower case F).
BTW: If you use Qt Creator as your IDE, just go to the header file, put the cursor on a method name and press alt-return, this will add a stub implementation in your .cpp file with all the spelling and upper/lower case done right :)
Hi,
I’m just starting too. At this point in time it seems the following will work
The most reasonable place to place it is in the TextFinder constructor, so it looks like this:
- ui(new Ui::TextFinder)
- {
- ui->setupUi(this);
- loadTextFile();
- }
I am not sure why would you want it in a clicked event and no one corrected you. :)
Using version
Qt Creator 2.4.1
Based on Qt 4.8.0 (64 bit)
Built on Mar 21 2012 at 22:53:22
The most reasonable place to place it is in the TextFinder constructor, so it looks like this: @TextFinder::TextFinder(QWidget *parent) : QWidget(parent), ui(new Ui::TextFinder) { ui->setupUi(this); loadTextFile(); QMetaObject::connectSlotsByName(this); }@
Yeah, thanks Byro! It works. In the Tutorial is not written where to place the QMetaObject::
Also they want the className “TextFinder” – this dosn’t work.
This is my first work with Qt – I looked for the mistake half the night. :-(
Now I’m HAPPY!
@Volker: Thanks for your advice! Sounds very useful. :-)
Sorry, I hope you’ll understand my bad english – had been a bad teacher in school – 43 years ago. :-)
You must log in to post a reply. Not a member yet? Register here!


