create a custom slot, hints?
Hi. I've read as much info as i could about creating custom slots, but i still cant get it work, maybe you could give me i hint about what im i doing wrong? The idea is, that when i priss button b, my custom slot 'print' shoud execute, but nothing happens! (no compilation errors or warnings either) :(
Code:
#include <QApplication>
#include <QPushButton>
#include <QWidget>
#include <qmessagebox.h>
{
public:
public slots:
void print();
};
void MyWidget:: print()
{
QMessageBox::information(this,
"Some window label here",
"hello");
}
MyWidget
::MyWidget(QWidget *parent
){
setFixedSize(200, 120);
quit->setGeometry(62, 40, 75, 30);
connect(b, SIGNAL(clicked()), this, SLOT(print()));[/B]
}
int main(int argc, char *argv[])
{
MyWidget widget;
widget.show();
return app.exec();
}
Re: create a custom slot, hints?
* add Q_OBJECT to your class
* add your header file to your .pro file's HEADERS section
(or include "#include "yourfile.moc" in yourfile.cpp if your class decl is in your .cpp file)
PS: at the moment you should get a runtime warning that this slot does not exist
HTH