Hi,
I did this:
main.cpp
#include <QApplication>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>
#include <QString>
{
public:
signals:
public slots:
void setTextLabel();
};
void MyWidget::setTextLabel()
{
label->setText("Test");
}
MyWidget
::MyWidget(QWidget *parent
) :{
QObject::connect(quit,
SIGNAL(clicked
()),
qApp,
SLOT(quit
()));
QObject::connect(showtext,
SIGNAL(clicked
()),
this,
SLOT(setTextLabel
()));
layout->addWidget(label);
layout->addWidget(showtext);
layout->addWidget(quit);
setLayout(layout);
}
int main(int argc, char *argv[])
{
MyWidget widget;
widget.show();
return app.exec();
}
#include <QApplication>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>
#include <QString>
class MyWidget : public QWidget
{
public:
MyWidget(QWidget *parent = 0);
QLabel *label;
QString string;
signals:
public slots:
void setTextLabel();
};
void MyWidget::setTextLabel()
{
label->setText("Test");
}
MyWidget::MyWidget(QWidget *parent) :
QWidget(parent)
{
QPushButton *quit = new QPushButton("Quit");
QPushButton *showtext = new QPushButton("Show");
label = new QLabel;
QObject::connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
QObject::connect(showtext, SIGNAL(clicked()), this, SLOT(setTextLabel()));
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(label);
layout->addWidget(showtext);
layout->addWidget(quit);
setLayout(layout);
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyWidget widget;
widget.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
But it gives me the following Application Output error:
Starting /home/simulab-3/Documentos/Qt/Training2010/Texto/Texto-build-desktop/Texto...
Object::connect: No such slot QWidget::setTextLabel() in ../Texto/main.cpp:37
So what is wrong?
Thank you very much!!!
Bookmarks