UI changes not reflecting when debugging
-
Hi. I am using Qt Creator with Qt version 6.3.0 with MSVC2019 64bit.
I was working on a project, and everything was going fine. However, suddenly I realized that the changes I was making to my .ui files were not getting reflected when I used to run the project on debug mode.
Upon searching about this problem, I found that I need to turn the 'Shadow Build' mode off. So I did this. However, when I run the application in debug mode now, at some point, it throws an exception, which was not coming earlier. Moreover, the exception is on an int variable declaration, which I have never seen before. It says
<optimized out>
, and a read access violation is thrown.
int index = 0
is the line.These exceptions were not being thrown when Shadow Build mode was on.
And all this started after I pushed my code to GitHub.
I am super confused as to what is happening. This has never happened before. Kindly help.
-
suddenly I realized that the changes I was making to my .ui files were not getting reflected
Are you sure you're changing the right file? Sounds silly, but you'd be amazed how many times people change the wrong file or in the wrong repo etc.
Look at the output pane after making a change in the .ui file. Is uic running on that file (uic is the thing that turns ui files into C++ code)? Is the compiler running on the resulting C++ file? Is the linker picking up that compiled file?
Delete your build directory and build your app again.
I found that I need to turn the 'Shadow Build' mode off
I don't know where you got that idea from but that's irrelevant. Shadow build is the recommended way to build your app, otherwise you're polluting your source dir. Debugging or running uic has nothing to do with it. It works either way.
Moreover, the exception is on an int variable declaration
That's just debugger getting lost, don't pay attention to it. There's nothing wrong in your int variable. Either your executable got out of sync with the debug information files or you're linking something incorrectly, e.g. debug executable with release Qt dlls or the other way around.
It says <optimized out>
Debug builds should not have optimizations turned on. Points even more into some mix up with your binaries i.e. sounds like you're debugging a Release executable. If it links into debug dlls it would explain the weird crashes too.
As I said earlier - delete the whole build dir and rebuild. verify that you're running and debugging the correct executable.
And all this started after I pushed my code to GitHub
That doesn't sound plausible. Unless you have some weird git scripts hooked up pushing changes to remote doesn't change the contents of your local dir.
-
Thank you for your reply.
I deleted the build directory, and rebuilt the program, but the problem still persisted.
Then I realized, that in my main directory (one with the source code, not the build directory), there were my ui_xxxx.h files. So, I understood that even though I was working on the correct files, the program was not reading the correct files.
So I deleted these ui_xxxx.h files from my main directory, and the problem got resolved. It started reading the correct files from the build directory following that.