PDA

View Full Version : connect returning false



thru
28th April 2009, 12:02
I am a very beginner learing by trial and error (well I have read a bit already). I was seeing the most simple example, dirview and I though I'd add some code, an object that would be signaled by the TreeView.

So I created a class derived from QObject with the Q_OBJECT macro and set a connection (code below) but the return value of connect is always false.

What I am missing?
And is there a way to get extended information of the error?



Receiver recv;
bool ok=QObject::connect(&tree,SIGNAL(activated(const QModelIndex &)),&recv,SLOT(selected(const ModelIndex &)));


this is the declaration of Receiver class:



class Receiver:public QObject{
Q_OBJECT;


public slots:
void selected(QModelIndex &);

};

spirit
28th April 2009, 12:09
And is there a way to get extended information of the error?

yes, there is a way, just take a look at console (output) and find something like "QObject::connect: ...".

thru
28th April 2009, 12:31
Thank you spirit! The error was no "such slot" so I reviewed and realized that I was not consistent with the const attribute of the QModelIndex parameter.

wysota
28th April 2009, 19:58
To me it seems you forgot "Q" in the signature of the slot.