Hi, my program is about animating the motion of the upper arm. currently there is 4 objects on my GUI. one is panelGL which displays the animation. then there is the horizontal slider, play button and reset button. i will first like to connect the slider to my panelGL so that the animation can be controlled by the slider. then i will like to connect the reset button and play button to the slider. the reset button will reset the value of the slider and thus also reset the animation to the initial position. the play button will start moving the slider, thus resulting in the animation of the arm from start till the end.
the problem i'm currently facing is as follows
Object::connect: No such slot MyPanelOpenGL::counterChanged(int) in mainwindow.cpp:19
Object::connect: (sender name: 'horizontalSlider')
Object::connect: (receiver name: 'panelGL')
Object
::connect: No such
slot QSlider::SetSliderValue() in mainwindow.
cpp:20Object::connect: (sender name: 'ResetButton')
Object::connect: (receiver name: 'horizontalSlider')
Object
::connect: No such
slot QSlider::animate() in mainwindow.
cpp:21Object::connect: (sender name: 'PlayButton')
Object::connect: (receiver name: 'horizontalSlider')
Object::connect: No such slot MyPanelOpenGL::counterChanged(int) in mainwindow.cpp:19
Object::connect: (sender name: 'horizontalSlider')
Object::connect: (receiver name: 'panelGL')
Object::connect: No such slot QSlider::SetSliderValue() in mainwindow.cpp:20
Object::connect: (sender name: 'ResetButton')
Object::connect: (receiver name: 'horizontalSlider')
Object::connect: No such slot QSlider::animate() in mainwindow.cpp:21
Object::connect: (sender name: 'PlayButton')
Object::connect: (receiver name: 'horizontalSlider')
To copy to clipboard, switch view to plain text mode
Any help will be appreciated and my code is
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTimer>
#include "main.h"
#include <QDebug>
extern QList<FileData> points;
int counter=0;
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->horizontalSlider, SIGNAL(valueChanged(int)),ui->panelGL, SLOT(counterChanged(int)));
connect(ui->ResetButton,SIGNAL(clicked()), ui->horizontalSlider, SLOT(SetSliderValue()));
connect(ui->PlayButton,SIGNAL(clicked()), ui->horizontalSlider, SLOT(animate()));
}
void MainWindow::counterChanged(int counter)
{
counter = ui->horizontalSlider->value();
}
void MainWindow::SetSliderValue()
{
ui->horizontalSlider->setValue(0);
}
void MainWindow::animate()
{
if ( counter < points.size()-1 )
{
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
counter++;
timer->start(1000);
}
}
MainWindow::~MainWindow()
{
delete ui;
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTimer>
#include "main.h"
#include <QDebug>
extern QList<FileData> points;
int counter=0;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->horizontalSlider, SIGNAL(valueChanged(int)),ui->panelGL, SLOT(counterChanged(int)));
connect(ui->ResetButton,SIGNAL(clicked()), ui->horizontalSlider, SLOT(SetSliderValue()));
connect(ui->PlayButton,SIGNAL(clicked()), ui->horizontalSlider, SLOT(animate()));
}
void MainWindow::counterChanged(int counter)
{
counter = ui->horizontalSlider->value();
}
void MainWindow::SetSliderValue()
{
ui->horizontalSlider->setValue(0);
}
void MainWindow::animate()
{
if ( counter < points.size()-1 )
{
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
counter++;
timer->start(1000);
}
}
MainWindow::~MainWindow()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
Bookmarks