Uploaded image for project: 'Qt Visual Studio Tools'
  1. Qt Visual Studio Tools
  2. QTVSADDINBUG-1127

Using 'include "[filename].moc"' fails

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 3.0.1
    • Build-time integration
    • None
    • Visual Studio 2022 17.7.4, Windows 11 Pro 10.0.22621 Build 22621, Qt Visual Studio Tool 3.0.1
    • Windows
    • e8ee4264b (dev)

    Description

      When a QObject class is declared in a cpp file with the Q_OBJECT macro, moc does not appear to be run on the file. The standard (though apparently poorly documented) way to make that happen has been to 'include "[filename].moc" ' at the bottom of the cpp file. That is not working with the 3.0.1 VS plugin.

      Example project attached - this builds fine with Qt Creator, or the 2.10 plugin.

      Build started...
      1>------ Build started: Project: testmoc, Configuration: Debug x64 ------
      1>Generate moc_predefs.h
      1>Moc'ing ./debug/moc_predefs.h...
      1>Moc'ing ./release/moc_predefs.h...
      1> C:\Users\Noah\source\repos\testmoc\debug\moc_predefs.h(0:1): note: No relevant classes found. No output generated.
      1> moc: C:\Users\Noah\source\repos\testmoc\release\moc_predefs.h: No such file
      1>C:\Users\Noah\AppData\Local\QtMsBuild\qt_globals.targets(272,5): error MSB4181: The "QtRunWork" task returned false but did not log an error.
      1>Done building project "testmoc.vcxproj" – FAILED.
      ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
      ========== Build started at 3:38 PM and took 01.486 seconds ==========

      Attachments

        1. testmoc.cpp
          0.6 kB
        2. testmoc.pro
          0.1 kB
        For Gerrit Dashboard: QTVSADDINBUG-1127
        # Subject Branch Project Status CR V

        Activity

          People

            mecfc Miguel Costa
            noah Noah Hamerslough
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes