Thanks for your quick response. It worked ! On Mon, Apr 4, 2011 at 9:38 PM, Nuno Martins <[email protected]>wrote:
> You header file is wrong: > > You have: > > private: > Ui::MainWindow *ui; > void joyConnect(); > void updateForm(); > > and it should be: > > private slots: > void joyConnect(); > void updateForm(); > > private: > Ui::MainWindow *ui; > > > On 04/04/2011 16:22, aadeesh bhagwatkar wrote: > > Sorry to bother you again with this. I know this is been asked/answered > before. I have searched (googled) and read a lot on this topic and tried > each and every instructions (moc, Q_OBJECT macro etc..) to solve this error. > > Finally i tried the mailing lists and found a solution: > > http://www.archivum.info/[email protected]/2010-02/00805/Re-%28Qt-interest%29-Runtime-Error--connect-No-such-slot-%28FIXED%29-But.html > > But still i am having the following runtime error. > > Starting >> /home/aadeesh/Project/Qt/gamepadReader/gamepadReader-build-desktop/gamepadReader... >> >> Object::connect: No such slot MainWindow::updateForm() in >> ../gamepadReader/mainwindow.cpp:11 >> >> Object::connect: (receiver name: 'MainWindow') >> >> >> Object::connect: No such slot MainWindow::joyConnect() in >> ../gamepadReader/mainwindow.cpp:12 >> >> >> Object::connect: (sender name: 'btnConnect') >> >> Object::connect: (receiver name: 'MainWindow') >> >> /home/aadeesh/Project/Qt/gamepadReader/gamepadReader-build-desktop/gamepadReader >> exited with code 0 >> >> > > I am using Qt Creator on Ubuntu 10.10. > My code files are: > > mainwindow.h > > #ifndef MAINWINDOW_H >> #define MAINWINDOW_H >> >> #include <QMainWindow> >> #include <QTimer> >> #include <joystick.h> >> >> namespace Ui { >> class MainWindow; >> } >> >> class MainWindow : public QMainWindow >> { >> Q_OBJECT >> >> public: >> explicit MainWindow(QWidget *parent = 0); >> ~MainWindow(); >> QTimer *timer; >> Joystick *joystick; >> >> private: >> Ui::MainWindow *ui; >> void joyConnect(); >> void updateForm(); >> }; >> >> #endif // MAINWINDOW_H >> > > mainwindow.cpp > > #include "mainwindow.h" >> #include "ui_mainwindow.h" >> >> MainWindow::MainWindow(QWidget *parent) : >> QMainWindow(parent), >> ui(new Ui::MainWindow) >> { >> ui->setupUi(this); >> timer = new QTimer(this); >> joystick = new Joystick(); >> connect(timer, SIGNAL(timeout()), this, SLOT(updateForm())); >> connect(ui->btnConnect, SIGNAL(clicked()), this, SLOT(joyConnect())); >> } >> >> void MainWindow::updateForm() >> { >> if(joystick->init(ui->joyInput->text().toAscii()) > -1) >> { >> ui->btnConnect->setText("Connected"); >> timer->start(); >> } >> } >> >> void MainWindow::joyConnect() >> { >> ui->axis1->display(joystick->getAxis(0)); >> ui->axis2->display(joystick->getAxis(1)); >> ui->axis3->display(joystick->getAxis(2)); >> ui->axis4->display(joystick->getAxis(3)); >> } >> >> MainWindow::~MainWindow() >> { >> delete ui; >> } >> > > main.cpp > > #include <QtGui/QApplication> >> #include "mainwindow.h" >> >> int main(int argc, char *argv[]) >> { >> QApplication a(argc, argv); >> MainWindow w; >> w.show(); >> >> return a.exec(); >> } >> > > > Please help me solve this error. An explanation will help me learn more. > Thank You. > -- > Aadeesh S. Bhagwatkar > > > _______________________________________________ > Qt-creator mailing > [email protected]http://lists.qt.nokia.com/mailman/listinfo/qt-creator > > > _______________________________________________ > Qt-creator mailing list > [email protected] > http://lists.qt.nokia.com/mailman/listinfo/qt-creator > > -- Aadeesh S. Bhagwatkar
_______________________________________________ Qt-creator mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-creator
