Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[VS2019] Intellisense doesn't recognize objectName change unless restart



  • Hi experts,

    I changed the objectName of a label from label to nameLabel, saved the .ui file but the change was not reflected in the .cpp file. Intellisense still shows label but the program won't build unless I changed it to nameLabel.

    I think this is an issue pretty similar to:
    https://forum.qt.io/topic/91053/changing-objectname-in-design-view-does-not-update-names-in-mainwindow-cpp

    Here are what I tried:

    • Re-build, didn't work
    • Re-open .ui file and save, didn't work
    • Check the ui_blah.h file and the name is indeed nameLabel, didn't work
    • Restart editor, finally worked!

    Question is: is there a way to solve this without restarting? I guess it's not a deal breaker but could be annoying from time to time.

    Thanks!


  • Moderators

    It's not a Qt specific thing. It's a general problem with generated or otherwise dynamic includes. For whatever reason intellisense sometimes gets stuck with the old information. This might be because the symbol info gets cached and VS fails to properly recognize a file change or associate it with the right dependent source files. It works for me most of the time, but occasionally intellisense stops updating. As you mentioned this doesn't affect the compiler. It's just annoying because you get the red squiggles and wrong code suggestions.

    I don't have a solid fix, but a workaround I found working most of the time is forcing intellisense to reparse by changing something in the file that includes the generated ui_blah.h file. Just add a space at the top or something like that and save. If not I fiddle with the include or the ui member decalration, e.g. comment it out, save, uncomment, save. It also sometimes takes a couple of seconds until it "catches on" after that, especially if the project is big or file has a lot of includes.



  • Thanks, I'll try that next time! BTW how do I mark this as an answer?


  • Moderators

    @Q74r3wq said:

    BTW how do I mark this as an answer?

    Click on the three dots icon under the post you want to mark and select "Mark this post as the correct answer".



  • @Chris-Kawa Somehow I don't see this option. Maybe because I'm a new user?


Log in to reply