Solved [VS2019] Intellisense doesn't recognize objectName change unless restart
-
Hi experts,
I changed the
objectName
of a label fromlabel
tonameLabel
, saved the.ui
file but the change was not reflected in the.cpp
file. Intellisense still showslabel
but the program won't build unless I changed it tonameLabel
.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-cppHere 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 indeednameLabel
, 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!
-
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 theui
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?
-
@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?