3

I had some messy code so I finally seperated it into headers and sources, but now I get 136 warnings saying

inline function 'void suchandsuch()' used but never defined

and errors

undefined reference to 'Widget::Widget(QWidget*)'

I've tried QMake, all the sources are in .pro file, rebuilding, cleaning and deleting all the moc files.

1 Answer 1

3

The first problem is in the inline functions. If you're familiar with template functions, inline functions have the same requirements. They need to have their implementation details included in the header file so that the compiler can generate the code inline whenever its included somewhere else. You can't implement then in the regular .cpp file.

As for the second problem, if Widget::Widget() is referring to the QWidget class and wasn't copy pasted from the error log, I'm guessing that it means your code isn't linking properly against the QtGui library. Make sure the .pro file doesn't have a line removing it as its otherwise included by default (aka, you don't want a line saying QT -= gui).

If that's not the problem and the Widget class it can't find a Widget(QWidget*) constructor for is your own class, then the problem might just be that there isn't an implementation in the widget's .cpp file for a Widget::Widget(QWidget*) function.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.