I'm making changes to a form in Creator but when I build the changes are not being "refreshed".
I've gone so far as to remove every element from the form and get rid of every stylesheet but when I build the project I get the same result; as if I had never made a change at all.
What gives? Am I missing something obvious? (obvious to everyone but me.. obviously)
I guess you're using QtCreator 2.0? I found the same strange issue. You have two options:
Remove the ui_{the_name_of_design}.h from the project's build dir. Then run qmake again.
make clean or Build → Rebuild All
But the second option even doesn't help with me. By the way that's why is good to use a different build dir than that where the sources are. If some changes don't appear to be applied, just delete the content of build dir, and everything goes fine as well.
Cheers
Most likely cause if that your make procedure is not noticing the changes in the .ui file, and so it is not calling the uic tool. Try to do a make clean to see if it helps, and check your build log to see if uic is being called.
For me, the solution was to change the BuildDirectory to the same directory where the code is, instead of the **-build-desktop directory.
I stumbled upon this issue as well and one thing I noticed was that my program was still running in the background without me knowing. Ending the task through task manager fixes it and you can make changes again.
A few suggestions:
Perform a make distclean.
Use a shadow build directory. Building “inside” the source code is not advised.
Check your computer’s clock and the date and time of your files.
This thread is a little dated but since I got caught up in the same problem I thought I would share how I resolved this.
I've been incrementally building up a ui with designer under QtCreator 2.4.1/Qt 4.8.1 using a poor man's source control approach: snapshots. At one point I inadvertently created a non-shadowed build project. In a subsequent snapshot I reverted the project back to shadow build and at that point new widgets added in the ui form were no longer being recognized in the build.
Solution:
Delete stale ui_.h files from the source directory.
Delete make and ui_.h files from your shadaow build directory.
Rebuild
Latest generated ui_.h files will reappear in the shadow build directory.
No copies of ui_.h files appear in the source directory indicating that the stale files were taking precedence in the build order. Not obvious.
I have this problem and i solve it by changing the project path. I had stored the project in my flash memory when i had this problem, then i copy the project folder and it's build folder also in the Desktop and open it with QtCreator and the problem was solved.
Problem is indeed stale generated files in project source directory. This can happen both with genrated ui_*.h files, as well as with moc_*.* files. Below is not covered by existing answers, so here we go:
To remove generated files from the project source directory, without affecting Qt Creator settings or current shadow build directories, there are two principal ways, which can also be combined for extra coverage.
Go to Qt command prompt, go to project source directory and run these commands:
qmake -r
make clean
make distclean
1st one will recursively create makefiles. 2nd one will remove all files produced by building the project. 3rd one will remove the makefiles again. Then continue using shadow build from Qt Creator as before.
The problem with this is, it will leave files which are not part of the project. So if some files have been removed from project, related generated files may remain, and cause trouble if files with same name are added back. So even after this it is good idea to verify no ui_* or moc_* files remain, if you know you have removed files from project.
Use your version control software to first commit or stash/shelve all uncommitted changes, and then remove all unversioned (also otherwise ignored) files. For some version control software this may not be easy as git clean -dxf (beware, that will also lose uncommited changes and Qt Creator's custom project settings), and in that case it may be easier to just remove project source directory and get a clean checkout.
The problem with this is, if some generated files have accidentally been added to project, they will not be cleaned up with this. So it may still be a good idea to do the step 1 above too.
Above steps should be in sync so that after step 1, any files in source directory (except Qt Creators's projectname.pro.user and possible *~ backup files) should be under in version control.
Related
I'm coding on CLion and made this log in function. The tests are being made through the .exe because CLion's Terminal sometimes jacks up the I/O's. The problem is my .exe is not finding the files I'm specifying. It runs properly through the CLion terminal, but when shifting to the .exe it doesn't.
I've read that putting those files in the cmake-build-debug/ directory fixes the issue - and it does. Thing is, this is a group project, and by putting those files in that directory I'll constantly run into compatibility troubles when pulling from git - .cmake-build-debug would have to be pushed, thus i'd have to reload it every time. This doesn't seem very proper to me.
The other option is to put the .exe file and required .dll's in the main directory. Again, would have to update this file every single time i build the project, which also isn't a very practical solution.
So I'm asking for some help regarding what can I do to ensure my .exe searches for files in the main directory, not just on the cmake-build-debug directory. The directories are included in CMakeLists, and the .exe still doesn't find them. This is quite the issue. The project will also include some rudimental form of database, so file handling will be important. Would be nice to be able to code and build without having to manually change stuff around every single time.
I'm building some custom Qt components as a static library, but I can't get past the compilation phase.
My project is structured as follows:
Root:
- .h and . cpp files of the custom Qt components
- GeneratedFiles/Debug/ <-- here the MOC compiler puts the generated moc_*.cpp files ("Debug" is automatically deducted from the build configuration, so it's Release for release builds)
That's a pretty standard folder setup, but for whatever reason the compiler can't find only the moc files. Anything that is in the root folder builds just fine, but the moc files are not found. Please note, the moc_ files are generated just fine and exist where they're supposed to be, with the correct content. The problem seems to be in the evaluation of the path GeneratedFiles\Debug\moc_whatever.cpp.
Interestingly enough, if I move a moc file (say, moc_example.cpp) in the root folder and manually adapt the call to CL.exe to compile moc_example.cpp instead of GeneratedFiles\Debug\moc_example.cpp, the file gets built.
I'm using VS 2017 version 15.7.1, CL is version 19.00.24215.1 for x64 and I'll update the question with any other detail might be useful, just add ask in a comment.
So... Why is the compiler telling me those files do not exist?
I finally solved this rebuilding the directory structure in a new directory. Apparently, using WSL's git to check out repositories under Windows breaks something in the filesystem in a way that is invisible from Explorer or Ubuntu's command line, but that breaks the compiler (and Visual Studio's intellisense).
Checking out the repository with Git for Windows seems to avoid causing the same problem.
I am working with Eclipse Luna with CDT plug-in.
Whenever I build the project it keeps rebuilding all files, even if I just modify specific .cpp file.
I use project -> build project for the build.
I also removed build automatically option (and re-opened eclipse), but it did not solve the problem.
I've searched a lot for similar questions, but found none.
Are you using a manually-managed Makefile project, i.e. one that is not automatically-managed by the CDT plugin? If so, perhaps you could post your Makefile contents here, because there may be issues with the target dependencies in it.
The File | New | C++ Project | Executable option creates a project in which CDT automatically creates and updates the Makefiles itself - in this setup, the dependencies (while not perfect, because there are a few bugs in CDT in this respect) should be managed well enough so that it won't rebuild the entire project just because one file changed.
On the other hand, if you imported an existing project via the menu File | New | Makefile Project with Existing Code (which I didn't previously mention), then you would have had to copy the Makefile from the existing project manually, as CDT doesn't copy it for you, or you would have had to manually create a Makefile.
As I mentioned previously, if you posted your Makefile (feel free to 'sanitise' it by removing any personal information), we might be able to determine why it's rebuilding all files when you've only updated one of them.
I would have posted this as a comment reply to your last comment, #davidgrandson, but apparently there's a fairly short limit on the length of these.
I have been following some tutorials for c++ game programing. I am kind of new to c++ and I'm using Microsoft Visual C++ 2010 Express IDE. I'm working on creating a game, and when I run the program through the IDE, it shows the grass sprites as expected. But when I run the .exe file from the Release folder, it shows weird images. and when I run the .exe file from the debug folder I get a grey screen. Can anybody tell me why this is happening?
I hazard to guess that your sprite images are kept as data files in your project folder. With that I offer the following premise:
The default run-location from the Visual Studio IDE is the project folder of the project which you're executing. That is, normally it executes from the directory where your .vcproj or .vcprojx file is kept (and that is often one folder below your solution directory folder, where your .sln file is kept).
If your project runs correctly from the IDE, but fails to run directly from the release folder, it is highly likely you are relying on project data files (images in your case) that are kept along side your source files in the project folder. When run from the Release folder, those files are no longer visible because your the Release folder is your working directory; not the project folder.
There are a number of ways to solve this problem, each with its own merits. A few options are:
Post Build Step
Make a post-build step for your project that copies your data files to the $(TargetDir) location with your project. These files will then be visible in the same directory as your executable.
Benefit: Its easy.
Drawback: It will always run if you click "build solution" even if the data files are "up-to-date."
Custom Build Targets
Add your data files to the project and write a Custom Build script that performs the same copy, but also establishes an output dependency file(s).
Benefit: Almost as easy as #1, but a little more tedious.
Drawback: You may have a lot of data files and each will require its own custom build step. (Note: you can multi-select all the data files in your project, and if you're creative with the built-in macros you can have them all use the "same" build rules and commands).
Embedded Resources
Add the data files as custom resources to your executable.
Benefit: Your project no longer requires data files side-by-side with the executable since they are embedded in the resource table of your EXE module.
Drawback: Custom code is required to dynamically load the custom resources from your executable's resource table rather than off-disk. It isn't difficult at all to do, but is additional work.
There are other options as well, but I hope this gives you some ideas to start with.
I use VS2008 and try to answer your question. Right click on the project and select properties on the bottom of popup, then go to Debugging under Configuration properties. You can see command you run and arguments you pass in IDE. I guess you miss some parameters.
So I'm pretty new to Qt, and I've just inherited a project from someone else who is also new to Qt. He isn't around this week btw. We are using Visual Studio 2008, and have the latest version of Qt installed(4.6.2).
The project builds on my coworker's machine fine, and I can get the project from svn and build it directly. But under any other circumstances it refuses to build on my machine, and it doesn't give me much of an explanation why. Even if I just do a 'build clean' and then a 'build' it doesn't work. Any slight modification will make it fail.
When I try to build the entire project I get the error message:
1>Moc'ing MatrixTypeInterface.h...
1>moc: Cannot create
.\GeneratedFiles\Debug\moc_MatrixTypeInterface.cpp;.\GeneratedFiles\Debug\moc_matrixtypeinterface.cpp
1>Project : error PRJ0019: A tool
returned an error code from "Moc'ing
MatrixTypeInterface.h..."
The moc tool doesn't give any sort of error message as to why it isn't working, and I wasted most of yesterday trying to figure out why. I got the command that VS was using to call moc, and I entered in the command line myself. It didn't write anything to the screen.
Any ideas?
I finally found the answer. my coworker was back in the office today, and I used the build log off his machine to get his full moc command(about 4 lines long). Our moc commands were basically the same except at the very end. His command ended in:
-o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp"
My command ended with:
-o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp;.\GeneratedFiles\Debug\moc_matrixtypeinterface.cpp"
I checked the custom build step for that file, and removed the excess bit. After that the file compiled fine. I don't know how or why qt decided to add in this extra tidbit, but it did.
Thanks for your help guys. A couple of you suspected that it was a filesystem issue, and indeed a semicolon is not allowed in a windows filename. But I feel the root cause was Qt creating the wrong build string.
I'm accepting my own answer in the hope that it will help someone else.
It's most likely a filesystem error, you probably don't have a "GeneratedFiles" folder or don't have the correct permissions on it.
I have had issues where different versions of the moc and the add-in use "Generated" or "Generated Files" or "GeneratedFiles" for the folder. Check the settings on all the build steps.
Its possible that your .vcproj file is corrupted. I've had this issue before which resulted from having different versions of Qt and the Qt VS add-on ended up corrupting my .vcproj files. For a while, I had to manually fix the .vcproj file (My AdditionalDependencies="..." line was being swapped around and cut off for various header files that needed to be mocced, I was manually fixing these for every new header that needed to be mocced).
A clean reinstall of Visual Studios + Qt + Qt add-on ended up fixing this. Check your .vcproj file and see if its making sense.
Are you sure your file paths are correct and existing before moc runs? Since it appears that relative paths are provided to moc, I'd find out what moc's working directory is when it runs.
How was your .vcproj file generated? Was qmake used? Or cmake? Or was it by scratch?