0

I'm working on Qt and adding slots to my Qt Gui application is giving out the following error.

 symbol(s) not found for architecture x86_64.

when i comment out the slots block everything seems fine.

public slots:

Is there some kind of bug in QtCreator or am I doing something wrong.

I'm using Qt Creator 2.5.2 based on Qt 4.8.3(64-Bit) on Mac Osx 10.8 (mountain lion)

Edit: Here is my full class

#include <QMainWindow>
#include "qextserialport.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    QextSerialPort *port;

public slots:
    void onDataAvailable();
};
tez
  • 4,990
  • 12
  • 47
  • 67
  • Please quote the whole class declaration that contains the "public slots:" One thing we shall be looking out for is the correct use of Q_OBJECT declaration. – Darryl Miles Nov 18 '12 at 13:17
  • @DarrylMiles I have edited the question with full class declaration. – tez Nov 18 '12 at 13:28
  • Are you sure your use of namespace Ui is correct? what happens if you remove 'class MainWindow;' and move the closing brace of the namespace to the last line ? Or maybe you change 'class MainWindow ...' to 'class Ui::MainWindow ...' an incorrect namespace will cause symbol resolution failure. – Darryl Miles Nov 18 '12 at 13:31
  • I'm pretty sure there is nothing wrong with namespace.I made several other apps this way and there was no problem.The error comes only when I add slots.Anyway I did what you said and there's "unknown type name 'MainWindow' error – tez Nov 18 '12 at 13:42
  • But the type is Ui::MainWindow is not it (so therefore MainWindow will be unknown) ? Does this link help http://stackoverflow.com/questions/41590/how-do-you-properly-use-namespaces-in-c – Darryl Miles Nov 18 '12 at 13:43
  • Post complete link error message. Not just the summary. – Stephen Chu Nov 18 '12 at 18:10

1 Answers1

1

From the code you posted, it seems you didn't implement your slot function. So that would explain it.

If you did, then you might have to delete the makefile and regenerate it:

make distclean
qmake

So that the moc rules are updated.

Nikos C.
  • 50,738
  • 9
  • 71
  • 96
  • Holyyy ....... You are right. The error's name,that completely confused me.Thought it was some Mac OsX architecture related problem. Thanks :) – tez Nov 20 '12 at 17:04