Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to run MOC on files which are not part of a project?
Forum Updated to NodeBB v4.3 + New Features

How to run MOC on files which are not part of a project?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 479 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Greg_Phil
    wrote on last edited by
    #1

    I there a way to let the Meta-Object Compiler run on header-files which are not explicitly added to project but only included?
    The docu states https://doc.qt.io/qt-6/moc.html:
    "The moc tool reads a C++ header file. If it finds one or more class declarations that contain the Q_OBJECT macro, it produces a C++ source file containing the meta-object code for those classes",
    If this statement is correct, then the moc tool doesn't read the header files which are not explicitly added to project. It there a way to force him, to do so?
    One coding lot header-only will face the problem sooner or later.
    Thank you in advance.

    Christian EhrlicherC 1 Reply Last reply
    0
    • G Greg_Phil

      I there a way to let the Meta-Object Compiler run on header-files which are not explicitly added to project but only included?
      The docu states https://doc.qt.io/qt-6/moc.html:
      "The moc tool reads a C++ header file. If it finds one or more class declarations that contain the Q_OBJECT macro, it produces a C++ source file containing the meta-object code for those classes",
      If this statement is correct, then the moc tool doesn't read the header files which are not explicitly added to project. It there a way to force him, to do so?
      One coding lot header-only will face the problem sooner or later.
      Thank you in advance.

      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Greg_Phil said in How to run MOC on files which are not part of a project?:

      If this statement is correct, then the moc tool doesn't read the header files which are not explicitly added to project. It there a way to force him, to do so?
      One coding lot header-only will face the problem sooner or later.

      No you won't - as soon as you have to moc a header for a library the library is no longer header-only.
      apart from this see qt_wrap_cpp

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      G 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        @Greg_Phil said in How to run MOC on files which are not part of a project?:

        If this statement is correct, then the moc tool doesn't read the header files which are not explicitly added to project. It there a way to force him, to do so?
        One coding lot header-only will face the problem sooner or later.

        No you won't - as soon as you have to moc a header for a library the library is no longer header-only.
        apart from this see qt_wrap_cpp

        G Offline
        G Offline
        Greg_Phil
        wrote on last edited by
        #3

        @Christian-Ehrlicher Thank you for the hint. I will try AUTOMOC, I'm using Cmake anyway.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved