Question

So I have a Q_OBJECT tagged class, which requires pregenerated .moc to be usable.

In my .qbs file, I have a CppApplication item; this seems to be the wrong type of project, as qbs does not call moc ClassName.cpp to generate moc's for me. What should be used instead/tweaked?

-

So I knew about Qt.core dependency, but it wasn't working on my crippled install of Qt; while I was trying to fix it, these facts came up:

  • It was required to detect Qt toolchain (qbs-setup-qt) and call qbs-config-ui
  • Qbs indeed stores the build rules in core.qbs, linked in via Qt/core dependency.
    • it's possible to copy/paste the build rules into my own .qbs file and avoid external dependencies; I'm considering this as a dirty hack for deploying the code on really crippled build systems (now I have a word for Qt support on Gentoo).
Was it helpful?

Solution

I think you might be missing the dependency of the application on the Qt-modules. The rule for generation of the moc files is part of the Qt.core module. You might add this dependency with:

CppApplication {
    name: "MyApp"
    files: "path_to_source/**"

    Depends { name: "Qt.core" } // Optional
    Depends { name: "Qt.widgets" }
}

As all other Qt modules have an implicit dependency on Qt.core the explicit dependency could on Qt.core could be skipped if there is a dependency on a different Qt-module (Qt.widgets in this example).

More details could be found at http://doc.qt.io/qbs/qt-modules.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top