jorgeg922
5th February 2017, 01:36
I have these 3 files below. Basically, I made a method in file LeptonTemp.cpp which I would like to link to a QPushButton. I instantiated the class into my main.cpp file, but when I try to place my method (doSomething) in SLOT, Im getting an error at compilation. Can anyone tell me what I am doing wrong?
LeptonTemp.cpp
LeptonTemp::LeptonTemp(){}
LeptonTemp::~LeptonTemp(){}
void LeptonTemp::doSomething(){
qDebug<<"Hello World";
}
LeptonTemp.h
class LeptonTemp
{
public:
LeptonTemp();
~LeptonTemp();
public slots:
void doSomething();
};
main.cpp
int main (int argc, char **argv)
{
QApplication a(argc, argv);
QWdiget *myWidget = new QWidget;
myWidget->setGeometry(400,300,340,290);
QPushButton *internalTmp = new PushButton("Internal temp", myWidget);
internalTmp->setGeometry(320,290,100,30);
LeptonTemp *temp = new LeptonTemp();
QObject::connect(internalTmp, SIGNAL(clicked()), temp, SLOT(doSomething)));
myWidget->show();
return a.exec;
}
LeptonTemp.cpp
LeptonTemp::LeptonTemp(){}
LeptonTemp::~LeptonTemp(){}
void LeptonTemp::doSomething(){
qDebug<<"Hello World";
}
LeptonTemp.h
class LeptonTemp
{
public:
LeptonTemp();
~LeptonTemp();
public slots:
void doSomething();
};
main.cpp
int main (int argc, char **argv)
{
QApplication a(argc, argv);
QWdiget *myWidget = new QWidget;
myWidget->setGeometry(400,300,340,290);
QPushButton *internalTmp = new PushButton("Internal temp", myWidget);
internalTmp->setGeometry(320,290,100,30);
LeptonTemp *temp = new LeptonTemp();
QObject::connect(internalTmp, SIGNAL(clicked()), temp, SLOT(doSomething)));
myWidget->show();
return a.exec;
}