Hello everybody, I need some help in a program i am creating. First of all , in my Program i use the QLabel, QSpinbox and QPushButton Widgets. What i need from that program is When i Click the Button to Copy the Value of the Spinbox and Paste it on the Label. I have done whatever possible but it brings me a warning at QObject slot. Let me show you the codes:
mypage.h
#ifndef MYPAGE_H
#define MYPAGE_H
#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QSpinBox>
class QLabel;
class QSpinBox;
class QPushButton;
namespace Ui {
class Mypage;
}
class Mypage : public QWidget
{
Q_OBJECT
public:
explicit Mypage(QWidget *parent = 0);
~Mypage();
private slots:
void pushButtonClicked();
private:
Ui::Mypage *ui;
QLabel *label;
QSpinBox *numberBox;
QPushButton *pushButton;
};
#endif // MYPAGE_H
mypage.cpp
#include "mypage.h"
#include "ui_mypage.h"
#include <QtGui>
#include <QPushButton>
#include <QLabel>
#include <QSpinBox>
Mypage::Mypage(QWidget *parent) :
QWidget(parent),
ui(new Ui::Mypage)
{
numberBox = new QSpinBox;
numberBox->setRange(0, 1000);
QLabel *label= new QLabel;
QPushButton *pushButton = new QPushButton;
ui->setupUi(this);
// Here is the Spot that doesn't work. It says that there is no such Slot
QObject::connect(pushButton, SIGNAL(clicked()), this, SLOT(pushButtonClicked()));
}
void Mypage::pushButtonClicked()
{
label -> setNum(numberBox->value());
}
Mypage::~Mypage()
{
delete ui;
}
Thank you
↧