Qt - no such signal error

Posted by bullettime on Stack Overflow See other posts from Stack Overflow or by bullettime
Published on 2010-04-09T19:08:16Z Indexed on 2010/04/09 19:13 UTC
Read the original article Hit count: 400

Filed under:
|

I'm trying to trigger a signal when a double click happens in one of the draggable widgets on the fridge magnets example. Here's the changes I made to the example source:

DragLabel:

class DragLabel : public QLabel
{
public:
    DragLabel(const QString &text, QWidget *parent);
    QString labelText() const;

public slots:
    void testSlot(){qDebug()<<"testSlot";}    //<-- implemented this slot

protected:
    void mouseDoubleClickEvent(QMouseEvent *ev){emit testSignal();}    //<-- overriden this method

private:
    QString m_labelText;

signals:
    void testSignal();    //<-- added this signal

};

The only thing I changed in the implementation file is adding connect(this,SIGNAL(testSignal()),this,SLOT(testSlot())); to DragLabel's constructor.

Trying to compile the project resulted in 'undefined reference to `DragLabel::testSignal()' and 'collect2: ld returned 1 exit status' errors.

When I comment out the call to the signal, it compiles and runs, but gives off 'Object::connect: No such signal QLabel::testSignal() in draglabel.cpp' warning in the application output. Apparently testSignal() isn't being recognized as a signal.

What am I missing?

© Stack Overflow or respective owner

Related posts about qt

Related posts about signals-slots