Connecting two classes with slgnal and slot
Hi all,
I am trying to connect two classes with signals and slots but without any luck.
I have a formSessionList class which has FileName(QString filename) slot and FileVisitor class which has foundFile(QString filename) signal.
I create an FileVisitor object from formSessionList constructor.
FileVisitor filevisitor;
But I can not make a connection between them.
connect(filevisitor, SIGNAL(foundFile(QString filename)), this, SLOT(FileName(QString filename)));
I get this error:
no matching function for call to `formSessionList::connect(FileVisitor&, const char[29], formSessionList* const, const char[28])'
Does anyone has any idea?
Tnx,
Benjamin
Re: Connecting two classes with slgnal and slot
First of all, QObject::connect() takes pointers to the sender and the receiver. So if you allocate the "filevisitor" on the stack, you need to pass "&filevisitor". Secondly, you must not put parameter names inside the SIGNAL() and SLOT() macros. So probably it should be something like this:
Code:
connect(&filevisitor,
SIGNAL(foundFile
(QString)),
this,
SLOT(FileName
(QString)));
Re: Connecting two classes with slgnal and slot