Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. VS2022 Qt Addin moc problem
Qt 6.11 is out! See what's new in the release blog

VS2022 Qt Addin moc problem

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
5 Posts 2 Posters 1.9k Views 2 Watching
  • 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.
  • S Offline
    S Offline
    scho
    wrote on last edited by
    #1

    Hello,

    we are currently determining which build system is most suitable for us to move away from qbs. One of them is Visual Studio with the Qt addin.
    The current problem is that the moc has to run on cpp's too.

    67410a53-a33b-46a8-ac31-8c1161ead709-image.png

    However, I get the error message that the file does not exist. Is there a way to achieve this using the Qt addin or does it have to be done via an additional project step?

    Chris KawaC 1 Reply Last reply
    0
    • S scho

      Hello,

      we are currently determining which build system is most suitable for us to move away from qbs. One of them is Visual Studio with the Qt addin.
      The current problem is that the moc has to run on cpp's too.

      67410a53-a33b-46a8-ac31-8c1161ead709-image.png

      However, I get the error message that the file does not exist. Is there a way to achieve this using the Qt addin or does it have to be done via an additional project step?

      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @scho Select the .cpp file in solution explorer and go to its properties. In the General section change the Item Type from C/C++ compiler to Qt Meta-Object Compiler (moc).

      1 Reply Last reply
      0
      • S Offline
        S Offline
        scho
        wrote on last edited by scho
        #3

        Hello @Chris-Kawa ,

        sorry for the late reply.
        Thanks, that helped!
        Now I have the problem that the project can't find the Qt classes from core.

        The error message is that QtRunWork returned false. After searching, it was recommended to install an older version of Qt Tools. Is it recommended to try the versions for Visual Studio 2022?

        Thanks for the help!

        Chris KawaC 1 Reply Last reply
        0
        • S scho

          Hello @Chris-Kawa ,

          sorry for the late reply.
          Thanks, that helped!
          Now I have the problem that the project can't find the Qt classes from core.

          The error message is that QtRunWork returned false. After searching, it was recommended to install an older version of Qt Tools. Is it recommended to try the versions for Visual Studio 2022?

          Thanks for the help!

          Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @scho said:

          Now I have the problem that the project can't find the Qt classes from core.

          Do you have the core module selected in the project settings? Do you have the includes for those classes?

          it was recommended to install an older version of Qt Tools

          I mean you can try, but I doubt it will change anything. I have no problem running apps on the latest version of the extension. I would rather guess that your app is missing some runtime dependency (a needed dll can't be found) and it just doesn't start because of that.

          Is it recommended to try the versions for Visual Studio 2022?

          You need the version for the VS version you're using, so if you're using VS2022 use the extension for VS2022. If you're using older version of VS then use the extension for that. AFAIK Visual Studio won't let you install an extension for different version.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            scho
            wrote on last edited by
            #5

            Hello @Chris-Kawa,

            we tried many things and found a solution for our problem.
            The main problem was the given Includes are ignored.

            missing_cc++_tree_branch_3.PNG

            We set "Override C/C++ Properties" to "Extend" and append all include paths in "Additional Inlucde Directories".
            missing_cc++_tree_branch_2.PNG

            Is that a bug?

            We got another little problem with the C/C++ Preprocessor Defines. We cant set them because in the project was only one cpp file in our project and this is set to moc.
            We had to add a dummy.cpp file so you can get the C/C++ tree tab.
            missing_cc++_tree_branch.PNG

            Thanks for your help.

            1 Reply Last reply
            0
            • S scho has marked this topic as solved on

            • Login

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