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
I changed the
objectNameof a label from
nameLabel, saved the
.uifile but the change was not reflected in the
.cppfile. Intellisense still shows
labelbut the program won't build unless I changed it to
I think this is an issue pretty similar to:
Here are what I tried:
- Re-build, didn't work
.uifile and save, didn't work
- Check the
ui_blah.hfile 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.
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.hfile. Just add a space at the top or something like that and save. If not I fiddle with the include or the
uimember 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?
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?