Arpitgarg
6th March 2011, 13:58
I wrote the following code,and getting error::
1. no void MainWindow::joyConnect() member function in class MainWindow.
2. no void MainWindow::updateForm() member function in class MainWindow.
3. btnConnect not declared in scope.
>>>>>>>>>>>>>>>>>>>>>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTimer>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QTimer* timer = new QTimer(this);
new joystick = new Joystick();
connect(timer, SIGNAL(timeout()), this, SLOT(updateForm()));
connect(btnConnect,SIGNAL(clicked()),this, SLOT(joyConnect()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::joyConnect()
{
if(joystick->init(joyAccess->text().toAscii()) > -1)
{
ui->btnConnect->setText("Connected");
timer->start();
}
}
void MainWindow::updateForm()
{
ui->lcd1->display(joystick->getAxis(0));
ui->lcd2->display(joystick->getAxis(1));
ui->lcd3->display(joystick->getAxis(2));
ui->lcd4->display(joystick->getAxis(3));
if(joystick->getButton(0) > 0)
ui->label_1->setText("UP");
else
ui->label_1->setText(" Axis1");
if(joystick->getButton(1) > 0)
ui->label_2->setText("Down");
else
ui->label_2->setText(" Axis2");
if(joystick->getButton(2) > 0)
ui->label_3->setText("UP");
else
ui->label_3->setText(" Axis3");
if(joystick->getButton(3) > 0)
ui->label_4->setText("UP");
else
ui->label_4->setText(" Axis4");
}
1. no void MainWindow::joyConnect() member function in class MainWindow.
2. no void MainWindow::updateForm() member function in class MainWindow.
3. btnConnect not declared in scope.
>>>>>>>>>>>>>>>>>>>>>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTimer>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QTimer* timer = new QTimer(this);
new joystick = new Joystick();
connect(timer, SIGNAL(timeout()), this, SLOT(updateForm()));
connect(btnConnect,SIGNAL(clicked()),this, SLOT(joyConnect()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::joyConnect()
{
if(joystick->init(joyAccess->text().toAscii()) > -1)
{
ui->btnConnect->setText("Connected");
timer->start();
}
}
void MainWindow::updateForm()
{
ui->lcd1->display(joystick->getAxis(0));
ui->lcd2->display(joystick->getAxis(1));
ui->lcd3->display(joystick->getAxis(2));
ui->lcd4->display(joystick->getAxis(3));
if(joystick->getButton(0) > 0)
ui->label_1->setText("UP");
else
ui->label_1->setText(" Axis1");
if(joystick->getButton(1) > 0)
ui->label_2->setText("Down");
else
ui->label_2->setText(" Axis2");
if(joystick->getButton(2) > 0)
ui->label_3->setText("UP");
else
ui->label_3->setText(" Axis3");
if(joystick->getButton(3) > 0)
ui->label_4->setText("UP");
else
ui->label_4->setText(" Axis4");
}