daviddoria
9th February 2010, 14:14
I want to set the text of a label when I click a button.
I have a button called 'pushButton' and a label called 'label'.
My form class is like this (buttonform.h):
#ifndef BUTTONFORM_H
#define BUTTONFORM_H
#include "ui_buttonform.h"
class ButtonForm : public QWidget
{
Q_OBJECT
public:
ButtonForm(QWidget *parent = 0);
private slots:
//void pushButton_Clicked();
signals:
void pushButton_Clicked();
private:
Ui::ButtonForm ui;
};
#endif
In buttonform.cpp, I had this:
#include <QtGui>
#include "buttonform.h"
#include <iostream>
ButtonForm::ButtonForm(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
}
void ButtonForm::pushButton_Clicked()
{
ui.label->setText("hello");
}
but it tells me that pushButton_Clicked() is already defined in moc_buttonform.cxx.
How should I go about doing this?
Thanks!
Dave
I have a button called 'pushButton' and a label called 'label'.
My form class is like this (buttonform.h):
#ifndef BUTTONFORM_H
#define BUTTONFORM_H
#include "ui_buttonform.h"
class ButtonForm : public QWidget
{
Q_OBJECT
public:
ButtonForm(QWidget *parent = 0);
private slots:
//void pushButton_Clicked();
signals:
void pushButton_Clicked();
private:
Ui::ButtonForm ui;
};
#endif
In buttonform.cpp, I had this:
#include <QtGui>
#include "buttonform.h"
#include <iostream>
ButtonForm::ButtonForm(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
}
void ButtonForm::pushButton_Clicked()
{
ui.label->setText("hello");
}
but it tells me that pushButton_Clicked() is already defined in moc_buttonform.cxx.
How should I go about doing this?
Thanks!
Dave