Ok, I guess the reason I didn't know how to do that is that I didn't know how to associate the slot with a particular widget (the pushButton). I think the answer is that you don't - you just associate it with the form:
The problem now is that it says "No such slot ButtonForm:ushButton_SetLabelText(QString& txt)
Here is what I have:
buttonform.cpp
#include <QtGui>
#include "buttonform.h"
#include <iostream>
ButtonForm
::ButtonForm(QWidget *parent
){
ui.setupUi(this);
connect( this->ui.pushButton, SIGNAL( clicked() ), this, SLOT(pushButton_SetLabelText(QString& txt)) );
}
void ButtonForm::pushButton_SetLabelText(QString& txt)
{
this->ui.label->setText(txt);
}
#include <QtGui>
#include "buttonform.h"
#include <iostream>
ButtonForm::ButtonForm(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
connect( this->ui.pushButton, SIGNAL( clicked() ), this, SLOT(pushButton_SetLabelText(QString& txt)) );
}
void ButtonForm::pushButton_SetLabelText(QString& txt)
{
this->ui.label->setText(txt);
}
To copy to clipboard, switch view to plain text mode
buttonform.h
#ifndef BUTTONFORM_H
#define BUTTONFORM_H
#include "ui_buttonform.h"
{
Q_OBJECT
public:
private slots:
void pushButton_SetLabelText(QString& txt);
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_SetLabelText(QString& txt);
signals:
//void pushButton_Clicked();
private:
Ui::ButtonForm ui;
};
#endif
To copy to clipboard, switch view to plain text mode
main.cpp
#include <QApplication>
#include "buttonform.h"
int main(int argc, char *argv[])
{
ButtonForm buttonform;
buttonform.show();
return app.exec();
}
#include <QApplication>
#include "buttonform.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
ButtonForm buttonform;
buttonform.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
I feel like this is very close!
Thanks for your help,
Dave
Bookmarks