Qt and C++ - undefined reference to slot

Max Frai picture Max Frai · Jul 15, 2009 · Viewed 7.3k times · Source

I have a build error with a slot in Qt. I have an class which has a public slot:

void doSomething();

In constructor of this class i do:

this->connect( ui->textFrom, SIGNAL(returnPressed()),
               this, SLOT(doSomething()) );

I have QLineEdit - textFrom object. The build error is

../moc_mainwindow.cpp:66: undefined reference to `MainWindow::doSomething()'

:-1: error: collect2: ld returned 1 exit status

Help me, please (:

Answer

Wojciech Bederski picture Wojciech Bederski · Jul 15, 2009

void doSomething(); looks like a snip from the header file, did you implement the slot itself?