hi everyone,

i had written an application wherein there will be single pushbutton and when i click the button and set of comments will appear. i had written as the following:

Qt Code:
  1. class demo: public QWidget
  2. {
  3. public:
  4. demo(QWidget *parent=0,const char *name=0);
  5. ~demo();
  6. public slots:
  7. void change();
  8.  
  9. };
  10.  
  11. demo::demo(QWidget *parent,const char *name):
  12. QWidget(parent,name)
  13. {
  14. setMinimumSize(640,480);
  15.  
  16. QPushButton *clear= new QPushButton("clear",this,"clear");
  17. clear->setGeometry(10,10,50,20);
  18. clear->setFont(QFont("Times",12,QFont::Bold));
  19. connect(clear,SIGNAL(clicked()),this,SLOT(change()));
  20. }
  21.  
  22. demo::~demo()
  23. {
  24. }
  25.  
  26. void demo::change()
  27. {
  28. printf("\n change \n");
  29. }
To copy to clipboard, switch view to plain text mode 

this is all the code. but when i execute the program i get the error as

"QObject::connect: No such slot QWidget::change()
QObject::connect: (sender name: 'clear')
QObject::connect: (receiver name: 'unnamed')
".
but the same code works if i had declared the class in an header file and defined it in a cpp file and the main program in a main.cpp file.
can anyone say me why is this not working ? is my coding correct ?

thanks in advance,

saravanan