ahmetturan
12th February 2012, 16:44
i created one pushbutton and label in myClass.cpp;
QLabel *lbl=new QLabel();
QPushButton *btn=new QPushButton("button");
ui->tableWidget->setCellWidget(0,0,lbl);
ui->tableWidget->setCellWidget(0,1,btn);
i want that: when i click button, calendar will open and when i click calendar, date will be written on label.
and i want to use signal & slot.
i created these functions:
myClass.h
public:
QCalendarWidget *cal;
public slots:
void writeDate(QLabel *);
void func();
void openCal();
signals:
void calClicked(QLabel *);
myClass.cpp
connect(btn,SIGNAL(clicked()),this,SLOT(openCal()) ); //it works
connect(cal,SIGNAL(clicked(QDate)),this,SLOT(func( )));//it works
myClass *a,*b;
QObject::connect(a, SIGNAL(calClicked(lbl)), b, SLOT(writeDate(lbl)));//it never works
void myClass::func()
{
emit calClicked(lbl);
}
void myClass::writeDate(QLabel *lbl)
{
cal->close();
lbl->setText(cal->selectedDate());
}
but i always get error:QObject::connect: Cannot connect (null)::calClicked(lbl) to (null)::writeDate(lbl)
sorry for my english.
QLabel *lbl=new QLabel();
QPushButton *btn=new QPushButton("button");
ui->tableWidget->setCellWidget(0,0,lbl);
ui->tableWidget->setCellWidget(0,1,btn);
i want that: when i click button, calendar will open and when i click calendar, date will be written on label.
and i want to use signal & slot.
i created these functions:
myClass.h
public:
QCalendarWidget *cal;
public slots:
void writeDate(QLabel *);
void func();
void openCal();
signals:
void calClicked(QLabel *);
myClass.cpp
connect(btn,SIGNAL(clicked()),this,SLOT(openCal()) ); //it works
connect(cal,SIGNAL(clicked(QDate)),this,SLOT(func( )));//it works
myClass *a,*b;
QObject::connect(a, SIGNAL(calClicked(lbl)), b, SLOT(writeDate(lbl)));//it never works
void myClass::func()
{
emit calClicked(lbl);
}
void myClass::writeDate(QLabel *lbl)
{
cal->close();
lbl->setText(cal->selectedDate());
}
but i always get error:QObject::connect: Cannot connect (null)::calClicked(lbl) to (null)::writeDate(lbl)
sorry for my english.