PDA

View Full Version : problem with signals/slots



vaas
2nd April 2010, 12:18
hey guys.In my application i'm creating an instance of Dialogtest(a dialog i created).so whenever that dialog opens up and the user clicks on the find button it invokes finclicked() slot which will emit a signal .
I used the signal/slot connection mechanism to connect this emitted signal to a slot of the Mainwindow(parent of the dialog).
The code is compiling but when i run the app and press the find button of the dialog it gives the following error in Application output.



Object::connect: No such signal Dialogtest::csearch(const QString& a,Qt::CaseSensitivity cs)
Object::connect: (sender name: 'Dialogtest')
Object::connect: (receiver name: 'MainWindow')
Object::connect: No such signal Dialogtest::csearch(const QString& a,Qt::CaseSensitivity cs,const QString& c)
Object::connect: (sender name: 'Dialogtest')
Object::connect: (receiver name: 'MainWindow')


Dialogtest.h is:


.........
signals:
void csearch(const QString&,Qt::CaseSensitivity cs);
void csearch(const QString&,Qt::CaseSensitivity cs,const QString&);

private slots:
void enablefind();
void findclicked();
........


Dialogtest.cpp


if(ui->replaceEdit->isEnabled()){
rstring =ui->replaceEdit->text();
emit csearch(fstring,cs,rstring);
}
else{
emit csearch(fstring,cs);}


Mainwindow.h


protected slots:
void sear(QString& c,Qt::CaseSensitivity cs,QString& x);
void sear(QString& c,Qt::CaseSensitivity cs);


Mainwindow.cpp


//inside a function that opens a dialog;
t=new Dialogtest(this);
t->exec();
QObject::connect (t,SIGNAL(csearch(const QString& a,Qt::CaseSensitivity cs)),this,SLOT(sear(const QString& c,Qt::CaseSensitivity cs)));
QObject::connect (t,SIGNAL(csearch(const QString& a,Qt::CaseSensitivity cs,const QString& c)),this,SLOT(sear(const QString& a,Qt::CaseSensitivity cs,const QString& c)));


the slots sear() are defined in Mainwindow.cpp
plz help me with this.

aamer4yu
2nd April 2010, 12:36
In connect method we only give the argument types for signals and slots. We dont give the argument name.
So a, cs and c shouldn't be in the connect lines.

vaas
2nd April 2010, 14:16
thank u...and can any one tell me if it is possible in qt to create custom ui(like u see in Avast antivirus).can it be done using stylesheets or is there any other way(i want to change the title bar also)

Lesiok
2nd April 2010, 14:24
Read about style sheets (http://doc.trolltech.com/4.6/stylesheet.html)