PDA

View Full Version : QObject::connect says "no such signal"



MistaPain
30th October 2006, 15:35
Hi,

I've been trying to use a QSpinBox in my project. I would like to use the signal "valueChanged(int i)" (as described in the documentation), but at runtime QObject::connect complains that there is no such signal ;-(

I thought that something with my code was wrong. But even the following small application is suffering the same problem:

#include <QtGui>
#include <QApplication>

int main(int argc, char **argv)
{
QApplication app(argc, argv);

QSpinBox sB;

QObject::connect(
&sB, SIGNAL(valueChanged(int i)),
&app, SLOT(quit())
);

sB.show();
return app.exec();
}
http://img114.imageshack.us/img114/4158/blubcs8.png

I'm using QT 4.2.0 for Windows and MingW.

Can anyone spot the point where my mistake is? I'm really getting mad about this.

munna
30th October 2006, 15:46
try this




QObject::connect(
&sB, SIGNAL(valueChanged(int)),
&app, SLOT(quit())
);



In signal and slot you should only specify the variable type and not the variable name.

MistaPain
30th October 2006, 15:52
Interesting. I just tried some other signals and for example QAbstractSpinBox::editingFinished() and they seem to work. QObject::destroyed() works, too, but QObject::destroyed(&something) doesn't. :(

It seems that signals without parameters work, but all other fail. Can anyone reproduce this behaviour? :confused:

edit: Oh, munna. You're right. The naming was my mistake. Thank you very much for your help. I've been struggling more than an hour now.

aamer4yu
31st October 2006, 05:40
Even the


SIGNAL(valueChanged(int i))


is working fine with me. I am using Visual C++ 6.0 with Qt 4.2.0