PDA

View Full Version : no such slot



eGamer
24th June 2009, 08:36
i have declared a slot in the QuarterWidget class like this:

public slots:
void home();

and i tried to make the connection with the clicked() signal of a button on the GUI,
but the connection failed and i read on the output window :

Object::connect: No such slot SIM::Coin3D::Quarter::QuarterWidget::home().
notice that the word "Q_OBJECT" is written at the beginning of the class QuarterWidget.

any help ? :confused:

aamer4yu
24th June 2009, 08:50
Do you have Q_OBJECT declared in you class ? And can we see the declaration of the class ?

eGamer
24th June 2009, 08:56
class QUARTER_DLL_API QuarterWidget : public QGLWidget
{
typedef QGLWidget inherited;
Q_OBJECT

public:
explicit QuarterWidget(QWidget * parent = 0, const QGLWidget * sharewidget = 0, Qt::WindowFlags f = 0);
explicit QuarterWidget(QGLContext * context, QWidget * parent = 0, const QGLWidget * sharewidget = 0, Qt::WindowFlags f = 0);
explicit QuarterWidget(const QGLFormat & format, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0);
virtual ~QuarterWidget();


public slots:
void setHome(void);
void home();

};

i tried to debug the QObject::connect() line, and i found that no slot is found.

shentian
24th June 2009, 10:27
Does your build process generate a moc_quarterwidget.cpp file? If not, re-run qmake.

aamer4yu
24th June 2009, 10:32
And how do you connect ? Can we see the connect code ?
Also did you try rebuilding the whole application ?

eGamer
24th June 2009, 10:43
for sure and also i found the home() slot found in qt_metacall(...) method inside
moc_QuarterWidget.cpp.


but as i make the connection it returns false, i don't know why.

eGamer
24th June 2009, 10:46
And how do you connect ? Can we see the connect code ?
Also did you try rebuilding the whole application ?



QuarterWidget* viewer = new QuarterWidget();
QPushButton* b = new QPushButton("CLick ME",viewer);
b->setGeometry(0,0,80,40);
if( !QObject::connect(b,SIGNAL(clicked()),viewer,SLOT( home())) )
QMessageBox::warning(0,"Error","Failed to Connect Slots Signals");


also i have rebuild the whole SOLUTION.

nish
24th June 2009, 10:53
Object::connect: No such slot SIM::Coin3D::Quarter::QuarterWidget::home().

you first posted this error. so how many classes this class is inheriting?

eGamer
24th June 2009, 10:56
you first posted this error. so how many classes this class is inheriting?

QuarterWidget only inherits from QGLWidget, but what you see is the namespaces.

nish
24th June 2009, 11:23
if all other slots of the class are working then try to rename the slot(wild guess i know). can u call this slot directly?

eGamer
24th June 2009, 12:58
if all other slots of the class are working then try to rename the slot(wild guess i know). can u call this slot directly?

no your advice is not "wild guess" because simply you solved my problem.

thank you very much, as i tried to call this slot the compiler showed "unresolved external"
though i was writing its implementation, then i discovered that there is an old version
of dll that visual studio is still binding to it, i simply deleted it and re-bind with the
new dll and everything is ok.

Thank You Very Much.