PDA

View Full Version : Signal and Slot connection not working !!



prakash437
17th May 2010, 01:11
Dear All,
I am pretty new to Qt and I accept this could well be a dumb question.

I dont understand why the slot connection is not working here !!

I have a simple form, with a button, and a tree widget. I have created a custom class for the tree widget, as in here and promoted it in the Qt designer !!



class QFileBrowser : public QTreeWidget
{
..
public slots:
void onFilesFoldersSelected();
};


The main window has a signal defined as follows !!


signals:
void filesFoldersSelected();


the signals and slot are connected as here !!


QObject::connect(this, SIGNAL(filesFoldersSelected()), ui->twFileBrowser, SLOT(onFilesFoldersSelected()));


But i see that i never land in the slot function. I have debugged and at the emitting part of the signal, it is assumed that nothing is connected.


if (!sender->d_func()->isSignalConnected(signal_index))
return; // nothing connected to these signals, and no spy .... returns here !! slot is not called !!


Could anyone please explain what I am doing wrong ??

Thanks for your time,
Prakash

high_flyer
17th May 2010, 08:34
are you sure you are emitting the signal?
Also, look at the debug output, if there is a problem with the signal slot connection a warning will be plotted to std output.

Lykurg
17th May 2010, 08:42
...and did you use the Q_OBJECT macro?

P.s.:
I am pretty new to Qt and I accept this could well be a dumb question. therefore we have Newbie section where we also help ;)

prakash437
17th May 2010, 10:16
Thank you guys for your answers !! I'm at work and I don't have the source code right now .. So I cannot confirm .. But i am sure, I missed out the Q_OBJECT macro definition :o :o !!!

Thanks again