0

I am developing a small QT library consisting of a widget and several helper classes which inherit QObject and use the Q_OBJECT macro. I want to hide the helper classes and put their definitions inside the CPP file. The problem is that QT's moc processes class definitions only in header file and thus I am getting a linker error. My questions are:

  • Is there any way to let mom handle a definition of a class in the CPP file if that class uses Q_OBJECT?
  • If not, what other ways would I have to hide the helper class?
user2683038
  • 667
  • 6
  • 17
  • 1
    How are you running `moc`? It works just fine on any file that contains valid `c++` code whether it be a `.hpp` file or `.cpp` or whatever. – G.M. May 27 '23 at 19:49
  • With the default settings. How can I set it up to include cpp files for the scanning? – user2683038 May 28 '23 at 04:44
  • I'm not sure what other tools you're using so I can't really comment on 'default settings'. But you might want to look at [this post](https://stackoverflow.com/questions/34928933/why-is-important-to-include-moc-file-at-end-of-a-qt-source-code-file). – G.M. May 28 '23 at 09:06

0 Answers0