2
votes

I am working with Qt 5.8 and VS Community 2015. When I define two or more signals in a class, for all signals except for the first one, VS will show a "function definition not found" warning. Also, I have started to run into weird linker/other issues after I started having multiple signals defined in my classes, which I think might be related. I would appreciate any information regarding this.

Update: When I delete the moc file, qmake won't re-moc it and will give linker errors. Update: The moc file looks normal. It has both signals implemented yet I'm still having this odd behavior.

class MyClass: public QObject{

public:
    MyClass() {}

private:
    Q_OBJECT

signals:
    void signal1(); // no warning
    void signal2(); // intellisense warns for no function definition

};

However, if I add signals: before every signal I define, I won't get such behavior.

class MyClass: public QObject{

public:
    MyClass() {}

private:
    Q_OBJECT

signals:
    void signal1(); // no warning
signals:
    void signal2(); // no warning

};
1
It means qmake isn't doing his job properly probably. If you have a look at the moc_xxx.h file corresponding to your class, does it generate the signal implementation ? - Adrien Leravat
@AdrienLeravat apparently it does. I don't know much about moc but when I checked the file, I could see that similar implementations are made for both signals. - Deniz
@AdrienLeravat I have updated my question. When I delete the moc file it won't re-moc it and just give linker errors. - Deniz
Ok... usually we put Q_OBJECT macro before the constructor but I doubt that changes anything. I haven't used Qt in VS in a long time, do you have any way to run qmake from the menus ? If I remember correctly, it creates the appropriate rules for VS to build the "moc_" files, and these rules are actually visible in project configuration. If so, qmake and/or adding it manually may solve the problem. - Adrien Leravat

1 Answers

0
votes

I had the same problem.

It disappeared just by restarting the Visual Studio.

I have noticed that sometimes when working with QT together with VS, there are some weird behavior/errors that solve just by restating the VS. I guess this is one of them...