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"
{
Q_OBJECT
public:
private slots:
//void pushButton_Clicked();
signals:
void pushButton_Clicked();
private:
Ui::ButtonForm ui;
};
#endif
#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
To copy to clipboard, switch view to plain text mode
In buttonform.cpp, I had this:
#include <QtGui>
#include "buttonform.h"
#include <iostream>
ButtonForm
::ButtonForm(QWidget *parent
){
ui.setupUi(this);
}
void ButtonForm::pushButton_Clicked()
{
ui.label->setText("hello");
}
#include <QtGui>
#include "buttonform.h"
#include <iostream>
ButtonForm::ButtonForm(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
}
void ButtonForm::pushButton_Clicked()
{
ui.label->setText("hello");
}
To copy to clipboard, switch view to plain text mode
but it tells me that pushButton_Clicked() is already defined in moc_buttonform.cxx.
How should I go about doing this?
Thanks!
Dave
Bookmarks