sar_van81
2nd April 2007, 06:30
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:
class demo: public QWidget
{
public:
demo(QWidget *parent=0,const char *name=0);
~demo();
public slots:
void change();
};
demo::demo(QWidget *parent,const char *name):
QWidget(parent,name)
{
setMinimumSize(640,480);
QPushButton *clear= new QPushButton("clear",this,"clear");
clear->setGeometry(10,10,50,20);
clear->setFont(QFont("Times",12,QFont::Bold));
connect(clear,SIGNAL(clicked()),this,SLOT(change() ));
}
demo::~demo()
{
}
void demo::change()
{
printf("\n change \n");
}
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
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:
class demo: public QWidget
{
public:
demo(QWidget *parent=0,const char *name=0);
~demo();
public slots:
void change();
};
demo::demo(QWidget *parent,const char *name):
QWidget(parent,name)
{
setMinimumSize(640,480);
QPushButton *clear= new QPushButton("clear",this,"clear");
clear->setGeometry(10,10,50,20);
clear->setFont(QFont("Times",12,QFont::Bold));
connect(clear,SIGNAL(clicked()),this,SLOT(change() ));
}
demo::~demo()
{
}
void demo::change()
{
printf("\n change \n");
}
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